I’m trying to register this simple script, but i can’t get this to show the message.
Any idea why my message won’t show??
Using asp.net framework 4.0.
Thanks.
String csName = "ChangeDivDir";
Type csType = this.GetType();
ClientScriptManager cs = Page.ClientScript;
if (!cs.IsClientScriptBlockRegistered(csType, csName))
{
StringBuilder csText = new StringBuilder();
csText.Append("<script type=\"text/javascript\">");
csText.Append(" var oDiv = document.getElementById(\"main\"); ");
csText.Append(" alert('My message'); ");
csText.Append("<script>");
cs.RegisterClientScriptBlock(csType, csName, csText.ToString());
}
Your last line is
<script>, but it should be</script>