| | |
message box in c# web application
Please support our ASP.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Sep 2007
Posts: 1,080
Reputation:
Solved Threads: 68
register a script for an "Alert":
C# Syntax (Toggle Plain Text)
string str = "function () { alert('OMG ITS me'); }"; Page.RegisterClientScriptBlock("nameofscript", str);
I answer pm's.
I answer questions.
I answer quickly.
I answer.
I answer questions.
I answer quickly.
I answer.
•
•
Join Date: Jun 2006
Posts: 12
Reputation:
Solved Threads: 0
Use the below mehtod
asp Syntax (Toggle Plain Text)
public static void ShowMessageBox(string message) { if (!string.IsNullOrEmpty(message)) { if (message.EndsWith(".")) message = message.Substring(0, message.Length - 1); } StringBuilder sbScript = new StringBuilder(50); //Java Script header sbScript.Append("<script type='text/javascript'>" + Environment.NewLine); sbScript.Append("// Show messagebox" + Environment.NewLine); message = message.Replace("\n", "\\n").Replace("\"", "'"); sbScript.Append(@"alert( """ + message + @""" );"); sbScript.Append(@"</script>"); // Gets the executing web page Page currentPage = HttpContext.Current.CurrentHandler as Page; // Checks if the handler is a Page and that the script isn't already on the Page if (currentPage != null && !currentPage.ClientScript.IsStartupScriptRegistered("ShowMessageBox")) { currentPage.ClientScript.RegisterStartupScript(typeof(Alert),"ShowMessageBox", sbScript.ToString()); } }
Last edited by peter_budo; Apr 5th, 2008 at 1:09 pm. Reason: Keep It Organized - please use [code] tags
Thanks,
Hosam Kamel
Hosam Kamel
•
•
Join Date: Aug 2008
Posts: 6
Reputation:
Solved Threads: 0
•
•
•
•
Use the below mehtod
asp Syntax (Toggle Plain Text)
public static void ShowMessageBox(string message) { if (!string.IsNullOrEmpty(message)) { if (message.EndsWith(".")) message = message.Substring(0, message.Length - 1); } StringBuilder sbScript = new StringBuilder(50); //Java Script header sbScript.Append("<script type='text/javascript'>" + Environment.NewLine); sbScript.Append("// Show messagebox" + Environment.NewLine); message = message.Replace("\n", "\\n").Replace("\"", "'"); sbScript.Append(@"alert( """ + message + @""" );"); sbScript.Append(@"</script>"); // Gets the executing web page Page currentPage = HttpContext.Current.CurrentHandler as Page; // Checks if the handler is a Page and that the script isn't already on the Page if (currentPage != null && !currentPage.ClientScript.IsStartupScriptRegistered("ShowMessageBox")) { currentPage.ClientScript.RegisterStartupScript(typeof(Alert),"ShowMessageBox", sbScript.ToString()); } }
Error 1 The type or namespace name 'Alert' could not be found (are you missing a using directive or an assembly reference?)
plz. help urgent...
thanx
![]() |
Similar Threads
- How to create a Comment Box/Guestbook in HTML (Site Layout and Usability)
- Explorer.Exe - Application Error (Windows NT / 2000 / XP)
- Write Your First Application in Win32 Using Assembly (Assembly)
- How To: Create a MessageBox Class for Web Forms in C# (C#)
- alert/message box (ASP.NET)
- bridge.dll and unable to download (Viruses, Spyware and other Nasties)
- Need a web server in intranet serve a external system (Networking Hardware Configuration)
- Reload page Error message when starting Windows XP (Viruses, Spyware and other Nasties)
- Small problem with web links? (Windows 95 / 98 / Me)
- Populating & Retrieving Data in a listbox : ASP.NET (w/ VB.NET) (ASP.NET)
Other Threads in the ASP.NET Forum
- Previous Thread: MultiLine TextBoxes in GridView edit mode
- Next Thread: asp:ListBox values not available when populated on client
| Thread Tools | Search this Thread |
Tag cloud for ASP.NET
.net 2.0 3.5 activexcontrol advice ajax asp asp.net bc30451 bottomasp.net browser businesslogiclayer button c# c#gridviewcolumn checkbox child class click compatible confirmationcodegeneration content contenttype control countryselector courier css database datagrid datagridview datagridviewcheckbox datalist deadlock deployment development dgv dropdownmenu dynamic edit embeddingactivexcontrol feedback findcontrol flash flv folder form forms google grid gridview homeedition hosting iframe iis javascript jquery list maps menu mobile mono mssql multistepregistration nameisnotdeclared novell objects order problem ratings refer rotatepage save search security serializesmo.table silverlight smartcard sql ssl suse textbox tracking treeview typeof unauthorized validation vb.net video view virtualdirectory vista visual-studio visualstudio vs2008 web webarchitecture webdevelopemnt webdevelopment wizard xml






