•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 375,219 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,279 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 3607 | Replies: 4
![]() |
•
•
Join Date: Sep 2007
Posts: 1,054
Reputation:
Rep Power: 3
Solved Threads: 61
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:
Rep Power: 3
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 12:09 pm. Reason: Keep It Organized - please use [code] tags
Thanks,
Hosam Kamel
Hosam Kamel
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb ASP.NET Marketplace
•
•
•
•
advertising article beta blog browser browsers community dani web daniweb data design development domains firefox forensic google help html intel internet java legal linux marketing mcafee michael knight microsoft monetization mozilla msn multimedia news opera php privacy report research search security software testing video w3c web web development webmaster wiki xml yahoo youtube
- 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)
- How to create a Comment Box/Guestbook in HTML (Site Layout and Usability)
- Explorer.Exe - Application Error (Windows NT / 2000 / XP / 2003)
- 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 9x / Me)
- Populating & Retrieving Data in a listbox : ASP.NET (w/ VB.NET) (ASP.NET)
Other Threads in the ASP.NET Forum
- Previous Thread: Parent-child relation in asp.net datagrid control
- Next Thread: VB.net/ASP.net SELECT problems with SQL



Linear Mode