Friday 29 November 2013

Passing parameter(Variable value) in ScriptManager.RegisterStartupScript.

Following Steps:

Only Alert:

string _alertValue = "Dear User: Your form" + " " + cmbFormName.SelectedValue.ToString()
                                 + " "      + "successfully";

                    ScriptManager.RegisterStartupScript(this, typeof(string), "OPEN_WINDOW", @"alert('" + _alertValue + "');window.frameElement.commitPopup();", true);



Only Redirect the Page


string ID = 25;
String test = “testabc:80”

string _alertPageRedirect = "http://" + test + "/TestForms/DisplayForm.aspx?ID=" + ID;


Page.ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "window.location.href = '" + _alertPageRedirect + "';", true);

 
Alert With Redirect

Page.ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "alert('Dear User: Please Contact Site Administrator.'); window.location.href = '"+_alertPageRedirect+"';", true);

No comments:

Post a Comment