TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Rahul Sharma
NA
20
9.4k
After starting System.timers.timer, not getting textbox value
Jun 18 2012 5:23 AM
Hi,
I am facing a problem.I have created a page in asp.net. Actually, this page will be filled by user. Page is too long i.e page has many controls. Sometimes, Session is expired while user is filling this page. or due to RTO(Request Timed Out) server problem. To prevent this problem, i have created a temporary table that will be updated after some time according to the timer control(System.timers.timer) interval. but, problem is that when i start timer on clickin a button, i dont get the value of any textbox control on that page after firing Elapsed event of timer. On the other way, when I fill values in all textboxes first and after that i start timer, then i get all textbox's values.Please give me some suggestion about this problem.Please help me.and my code is this .....
SqlConnection conn =
new
SqlConnection(
"
Data Source=A-E7F834CA56374;Initial Catalog=company;Integrated Security=True"
);
SqlCommand cmd =
new
SqlCommand();
System.Timers.Timer timer =
null
;
protected
void
StartTimer_Click(
object
sender, EventArgs e)
{
if
(timer ==
null
)
{
timer =
new
System.Timers.Timer(
10000
);
timer.Elapsed +=
new
System.Timers.ElapsedEventHandler(timer_Elapsed);
timer.Enabled =
true
;
timer.Start();
}
}
void
timer_Elapsed(
object
sender, System.Timers.ElapsedEventArgs e)
{
cmd.Connection = conn;
conn.Open();
cmd.CommandText =
"
Select * from employee where id='"
+ txtID.Text +
"
'"
;
SqlDataReader dr = cmd.ExecuteReader();
if
(!dr.HasRows)
{
dr.Close();
cmd.CommandText =
"
Insert into employee Values('"
+ txtID.Text +
"
','"
+ txtName.Text +
"
','"
+ txtSal.Text +
"
','"
+ txtDept.Text +
"
')"
;
}
else
{
dr.Close();
cmd.CommandText =
"
Update employee set name='"
+ txtName.Text +
"
',salary='"
+ txtSal.Text +
"
',city='"
+ txtDept.Text +
"
' where id='"
+ txtID.Text +
"
'"
;
}
cmd.ExecuteNonQuery();
conn.Close();
}
protected
void
StopTimer_Click(
object
sender, EventArgs e)
{
timer.Stop();
}
Please help me as soon as possible.
Thanks
(Rahul)
Reply
Answers (
1
)
i want to get key press event in asp.net as similar in window application...Pls tell how to override textbox properties??
How to display message box if any error occur in the page using c sharp?