Click here to Skip to main content
15,667,014 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello friends,

i am using this code which is given below on button click on my page but its not show the alert msg can any one guide me???

C#
Page.ClientScript.RegisterClientScriptBlock(GetType(), "Javascript", "<script>alert('Record Added Successfully')</script>");
Posted

For me this line is working fine.
Provide some code so that you will get the correct answer.
 
Share this answer
 
Comments
guptaadeepak 3-Oct-11 2:14am    
hello friend i am using the same code on button click and whole code is
protected void btupreview_Click(object sender, EventArgs e)
{

Page.ClientScript.RegisterClientScriptBlock(GetType(), "Javascript", "<script>alert('Record Added Successfully')</script>");
}

script is also mention here design part only one button on which click popup alert msg but when i am click on button alert popup is not working plz guide me?
P.Salini 3-Oct-11 2:36am    
can you give aspx code also.
Try To use this one

C#
ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "YOUR KEY", "YOUR SCRIPT", true);


or Try this..
First of add your script to your asp.net page's header tag
JavaScript
<script type="text/javascript">
function display(){
  alert('Record Added Successfully');
}
</script>


then in code behind page's pageload event write this..

C#
btnAdd.Attributes.Add("onclick", "display();");
 
Share this answer
 
If you are using update panel then Page.ClientScript wont work you have to use ScriptManager and give typeof as update panel.
 
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