Click here to Skip to main content
15,890,947 members
Please Sign up or sign in to vote.
3.50/5 (2 votes)
See more:
Hello Everyone,
I used the following code to display popup message but i am not getting any thing Please check this
C#
string  msg = "Unselected Sample ID's can't be deleted because they are used in other sections.";
ScriptManager.RegisterStartupScript(this, this.GetType(), "aa", "alert('" + msg + "');", true);

Thanks
Posted
Comments
TrushnaK 10-Jun-14 6:29am    
from where you call this code.. can you post bit more. that how you call this code
ErBhati 11-Jun-14 2:30am    
i call this code on checkbox_click event.

Hi ErBhati,

Try this..

string msg = "Unselected Sample ID\\'s can\\'t be deleted because they are used in other sections.";

ScriptManager.RegisterStartupScript(this, this.GetType(), "aa", "alert('" + msg + "');", true);


If any doubts regarding this, refer the link below:
http://stackoverflow.com/questions/5855670/why-using-javascript-escape-character-of-quotation-in-string-need-to-be-inst[^]
 
Share this answer
 
v3
XML
Hi

If you are using update panel in your page and want to display a message box then use the below

ScriptManager.RegisterStartupScript(this.UP, typeof(string), "Alert", "alert('Message here');", true);

If you don't have Update Panel then use the below

Response.Write("<script language=javascript>alert('Message here.')</script>");

Hope this helps.



Try using either the Page.RegisterStartupScript or ClientScript.RegisterStartupScript methods.
 
Share this answer
 
v2
You will think it is a joke, but remove the ; and it will work haha

C#
ScriptManager.RegisterStartupScript(Page, GetType(), "ShowPopup", "alert('Você não tem permissão para acessar essa página')", true);


also, notice that you should do it inside a Form, at least that was how I reproduced it.
 
Share this answer
 
Comments
ErBhati 11-Jun-14 2:32am    
thanks for reply ..and no i'm not think it is a joke but it is a code :D
How about this?

C#
Header.Controls.Add(new LiteralControl("<script type="\"text/javascript\"">alert('Hello');</script>"))
 
Share this answer
 
Try like this,

C#
Response.Redirect("<script>alert("Your Message")</script>");
 
Share this answer
 
Comments
ErBhati 10-Jun-14 6:21am    
not works for me...
just use below code:

Response.Write("<script>alert('Your Message')</script>");



Thanks,
-RG
 
Share this answer
 
Comments
ErBhati 10-Jun-14 6:21am    
not works for me...
Ramug10 10-Jun-14 6:35am    
do you have any update panel in your source?
Ramug10 10-Jun-14 6:37am    
generally in normal conditions above code works but I think pop is blocked by something.
ErBhati 10-Jun-14 6:42am    
no i have no update panel in my source code.
C#
ScriptManager.RegisterStartupScript(this, GetType(), "Alert", "alert('Hello There');", true);
 
Share this answer
 
Comments
ErBhati 10-Jun-14 6:20am    
please try ScriptManager.RegisterStartupScript(this, GetType(), "Alert", "alert('can't be deleted');", true);
then give 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