1) select value in dropdownlist
2) check related data in server-side with selected value
3) if data is valid, pass to other action; otherwise, alert error message and set the selected value back to origial one
Since some related data will be loaded from database, I cannot check the data in client side with javascript directly. So, I use above method to check data.
However, I have no idea on adding alert javascript when the data is not valid. Can anyone help me to solve this problem?
Phinehas
Member
362 Points
242 Posts
DropDownList and Alert
May 03, 2012 08:07 AM|LINK
Hi,
I would like to implement the following logic:
1) select value in dropdownlist
2) check related data in server-side with selected value
3) if data is valid, pass to other action; otherwise, alert error message and set the selected value back to origial one
Since some related data will be loaded from database, I cannot check the data in client side with javascript directly. So, I use above method to check data.
However, I have no idea on adding alert javascript when the data is not valid. Can anyone help me to solve this problem?
kedarrkulkar...
All-Star
35573 Points
5700 Posts
Re: DropDownList and Alert
May 03, 2012 08:33 AM|LINK
u can set alert to be shown from codebehind... after checking data in codebehind dropdown change event, add this line
if(data is not valid)
ScriptManager.RegisterStartupScript(this, this.GetType(), "script","javascript:alert('error message')", true);
hope this helps...
KK
Please mark as Answer if post helps in resolving your issue
My Site
sriramabi
Contributor
4351 Points
1277 Posts
Re: DropDownList and Alert
May 03, 2012 10:28 AM|LINK
hai
string script = "alert('Scores are updated successfully');window.location ='Default.aspx';";
ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", script, true);
ramiramilu
All-Star
98053 Points
14516 Posts
Re: DropDownList and Alert
May 03, 2012 11:06 AM|LINK
Think of CustomValidator....
Thanks,
JumpStart
Phinehas
Member
362 Points
242 Posts
Re: DropDownList and Alert
May 04, 2012 12:46 AM|LINK
May I know the statement written in VB.net?
Phinehas
Member
362 Points
242 Posts
Re: DropDownList and Alert
May 04, 2012 12:46 AM|LINK
May I know the statement written in VB.net?
kedarrkulkar...
All-Star
35573 Points
5700 Posts
Re: DropDownList and Alert
May 04, 2012 05:54 AM|LINK
try this
ScriptManager.RegisterStartupScript(Me, Me.GetType(), "script", "javascript:alert('error message')", True)
hope this helps...
KK
Please mark as Answer if post helps in resolving your issue
My Site