3 Replies - 3608 Views - Last Post: 19 November 2009 - 11:15 AM Rate Topic: -----

#1 susanwatson   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 18-November 09

Using Ajax Timer in C#.net

Post icon  Posted 18 November 2009 - 07:46 PM

Hi,
I want to add a text to label and enable a button after Timer1.Enabled = false in C#.net
This is what i have:


protected void btnStart_Click(object sender, EventArgs e)
	{
		
			  
		bool Flag = GetAnswer();  // this portion will just set Flag to true or false
		if (Flag == true)
		{
			Timer1.Enabled = false;
			btnStart.Enabled = true;
			Lable1.Text = "Flag is True";
			Timer1.Dispose();
		  
		}
		else
		{
			Timer1.Enabled = true;
			btnStart.Enabled = false;
			Lable1.Text = "Flag is False";
		 }		 
	}


	protected void timer1_Tick(object sender, System.EventArgs e)
	
	{
		btnStart_Click(null, EventArgs.Empty);
	}



The portion that Flag is false woks fine my problem is where Flag is True then nothing will happen to the page. I checked the OnPreRender portion. it will go to OnPreRender but not posting changes back to the page.
Thank you for your help in advance


Admin Edit: Please use code tags when posting your code. Code tags are used like so => :code:

Thanks,
PsychoCoder :)

This post has been edited by PsychoCoder: 19 November 2009 - 06:33 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Using Ajax Timer in C#.net

#2 PsychoCoder   User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1659
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Using Ajax Timer in C#.net

Posted 19 November 2009 - 06:33 AM

Moved to ASP.NET
Was This Post Helpful? 0
  • +
  • -

#3 ramesh866   User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 91
  • Joined: 03-October 09

Re: Using Ajax Timer in C#.net

Posted 19 November 2009 - 09:30 AM

can you show the code, of the GetAnswer(); func
Was This Post Helpful? 0
  • +
  • -

#4 susanwatson   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 18-November 09

Re: Using Ajax Timer in C#.net

Posted 19 November 2009 - 11:15 AM

View Postramesh866, on 19 Nov, 2009 - 08:30 AM, said:

can you show the code, of the GetAnswer(); func

it's just a boolean function that looks at the database, and checks for the flag, to see if it's true or false
public bool GetAnswer()
		{
			SqlCommand SqlCmd = new SqlCommand("dbo_GetAnswer");
			SqlCmd.CommandType = CommandType.StoredProcedure;
			bool Flag = false;
			DataTable dt = Filldt(SqlCmd, myconnectionstring);
			if (dt.Rows.Count > 0)
			{
				if (dt.Rows[0]["flag"] != System.DBNull.Value)
				{
					Flag = Convert.ToBoolean(dt.Rows[0]["flag"].ToString());
				}
			}
			return Flag;
		}


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1