//Response.Redirect("Results.aspx"); this statement works preety good
//btnNext_Click(this, null); this statement is not working, instead of this statement I have used "fun();" and btnNext(null,null)
//but both are not working.....
sec = 10;
Session["sec"] = sec.ToString();
}
Session["sec"] = sec.ToString();
lblScnds.Text = sec.ToString();
}
ShyamSDIT
0 Points
6 Posts
How to call button's click event without clicking that actual button in ASp.NET C#
Nov 17, 2012 07:00 PM|LINK
hello every one.. I am trying to develop online test....
my need is after some second, question must be changed..
so i have used ajax timer control.... the code is as below
public partial class Examination : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
// code to load first question of test...
}
}
protected void timer1_Tick(object sender, EventArgs e)
{
int sec;
sec = Convert.ToInt32(Session["sec"].ToString());
sec = sec - 1;
if (sec < 0)
{
//Response.Redirect("Results.aspx"); this statement works preety good
//btnNext_Click(this, null); this statement is not working, instead of this statement I have used "fun();" and btnNext(null,null)
//but both are not working.....
sec = 10;
Session["sec"] = sec.ToString();
}
Session["sec"] = sec.ToString();
lblScnds.Text = sec.ToString();
}
public void fun()
{
//code to fetch next question from DB
}
protected void btnNext_Click(object sender, EventArgs e)
{
fun();
}
// i have used btnNext.Click(null,null) or (this,null) but they doesn't work</p> <p>
// i have made sub, that i call when button is clicked, same call i made when seconds become zero, but there it doesn't work..
// Whats actual problem... can anybody say.. please..
chetan.sarod...
All-Star
65839 Points
11163 Posts
Re: How to call button's click event without clicking that actual button in ASp.NET C#
Nov 19, 2012 02:58 AM|LINK
Refer this similar threads
http://forums.asp.net/t/1720013.aspx/1
http://forums.asp.net/t/1713714.aspx/1
http://forums.asp.net/t/1829158.aspx/1
http://forums.asp.net/t/1817130.aspx/1
Senior Software Engineer,
Approva Systems Pvt Ltd, Pune, India.