Jump to content

How to use java script in asp.net 2.0 C#


discuss97

Recommended Posts

Hi .I want to add javascript code in c# file . So i use private void PopUpMessege(string msg) { string popupScript = "<script language='javascript'>" + "window.alert('" + msg + "'); window.open('Default2.aspx');</script>"; //Response.Write(popupScript); Page.RegisterStartupScript("PopupScript", popupScript); }PopUpMessege("Working");This code work properly but when i use any function in script it will not fuction correctly. There are error.. plz help me

private void timer()    {        string popupScript2 = "<script language='javascript'>" +                       "var seconds=0 "+ "var minutes=0 " + "document.d.d2.value='0' "+ "function display(){ "+"if (seconds>=59){ " + "seconds=0 " + "minutes+=1 "+ "if(minutes==2) "+ "{window.open('Default.aspx'); "+"} "+  "if(minutes==2) "+ "{window.open('Default.aspx'); "+ "} "+ "} "+ "else "+ "seconds+=1 "+ "document.d.d2.value=minutes+':'+seconds "+ "setTimeout('display()',100) "+ "} "+"display(); </script>";        Page.RegisterStartupScript("PopupScript2", popupScript2);}

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...