Jump to content

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


discuss97
 Share

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...