Click here to Skip to main content
15,911,711 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
ScriptManager.RegisterStartupScript(this, this.GetType(), "javascript", "if(confirm('are you sure?')==true){document.getElementById('" + hfMessageBoxValue.ClientID.ToString() + "').vale='YES'}else{document.getElementById('" + hfMessageBoxValue.ClientID.ToString() + "').vale='NO'}{document.getElementById('" + btnSavechecked.ClientID + "').click()}", true);

if (hfMessageBoxValue.Value == "YES")
 {
do something 
 }
else(hfMessageBoxValue.Value == "NO")
 {
do something
 }
Posted
Updated 22-Sep-14 4:10am
v2
Comments
Sinisa Hajnal 22-Sep-14 9:36am    
Again, you have typing errors. Is this exact copy of your code? not VALE, but VALUE

And also, again, make the function client side and call it just by name in register method.
ghanem90 22-Sep-14 10:07am    
i change vale to value but the same not working
ZurdoDev 22-Sep-14 9:50am    
Don't put that much code in a RegisterStartupScript call because it is way too hard to manage. Put the JS in a function in a JS file and then just call the function name in C#.
Kishore Pogaru 22-Sep-14 10:31am    
move your script to the aspx page of js file
Sinisa Hajnal 23-Sep-14 2:06am    
I've tried to tell him that in his original question, no luck :)

1 solution

You need to put your JavaScript into a file and then include it in your aspx page. Then call the function using ScriptManager.RegisterStartupScript.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900