Click here to Skip to main content
15,891,708 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have one problem when trying to make a commmon mehod that can be called in any button click

I have created one method and inside that message() function is there , now i want to call it from button click with title and content parameters
JavaScript
public static string ShowAlertMessage(string pHeader, string pError)
 {
StringBuilder strScript = new StringBuilder();
 strScript.Append("<script type=\"text/javascript\" src=\"").Append("Scripts/jquery-1.4.1.js").Append("\"></script>");
 strScript.Append("<script type=\"text/javascript\" src=\"").Append("Scripts/jquery.msgBox.js").Append("\"></script>");
 strScript.Append("<link rel=\"stylesheet\" type=\"text/css\" href=\"").Append("Styles/msgBoxLight.css").Append("\" />");
 strScript.Append("<script type=\"text/javascript\">");
 strScript.Append("function example()");
 strScript.Append("{");
 strScript.Append("$.msgBox({");
 strScript.Append("title:'" + pHeader + "'");
 strScript.Append(",");
 strScript.Append("content:'" + pError + "'");
 strScript.Append("});");
 strScript.Append("}");
 strScript.Append("</script>");
return strScript.ToString();
}


This method I am calling on each and every page on the button click where ever I required as follows
HTML
ClientScript.RegisterStartupScript(this.GetType(), "Popup", Alert.ShowAlertMessage("Hello", "Welcome"), true);

can some one help me please to achieve my requirement
Posted
Updated 2-Jun-13 23:44pm
v2
Comments
Prasad_Kulkarni 3-Jun-13 5:44am    
Where is the question?
hiteshcode 3-Jun-13 6:02am    
ok , i resolved it. Thanks
How did you resolve? And what was the problem?
Shubhashish_Mandal 5-Jun-13 4:16am    
if you resolved it ,plz provide the solution. It will help other
Sunasara Imdadhusen 3-Jun-13 8:17am    
Would you like to call your button click from server side or client side?

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