?
Solved

MessageBox Codebehind Parsing Javascript Errror?

Posted on 2009-02-13
13
Medium Priority
?
1,060 Views
Last Modified: 2012-05-06
I have a masterpages web .NET 3.5 and use Ajax UpdatePanel. I've tried either code examples to create a MessageBox popup window from C# codebehind via Javascript, but always recieve a page error:

[code]
Response.Write("<script language='javascript'>alert('Success');</script>");

[error]
Error parsing near '<script language='ja'.

--or--

[code]
Response.Write("<script language=Javascript>alert('Success');</script>");

[Error]
Error parsing near '<script language=Jav'.
0
Comment
Question by:pointeman
  • 6
  • 6
13 Comments
 
LVL 16

Accepted Solution

by:
burakiewicz earned 1000 total points
ID: 23633155
try this
ScriptManager.RegisterStartupScript(updatePanel1, updatePanel1.GetType, "Message", "alert('Success');", true);
0
 
LVL 11

Expert Comment

by:jmwheeler
ID: 23633715
Use burakiewicz's suggestion.  You cannot use Response.Write in a asynchronous call.  It will always cause an error.
0
 

Author Comment

by:pointeman
ID: 23633909
.. has invalid arguments...
ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType, "Message", "alert('Success');", true);
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 16

Assisted Solution

by:burakiewicz
burakiewicz earned 1000 total points
ID: 23633940
change this
UpdatePanel1.GetType
to
UpdatePanel1.GetType()
0
 
LVL 16

Expert Comment

by:burakiewicz
ID: 23633946
sorry about that
0
 

Author Comment

by:pointeman
ID: 23633983
I would also like to be able to call a javascript from a script folder as well.

protected void Button1_Click(object sender, EventArgs e)
{
      call ~/script/JScript.js function MessageBoxAlert(textstring)
}
 
0
 
LVL 16

Expert Comment

by:burakiewicz
ID: 23634020
if the script is registered on the page, you just call it like normal
then
string strExample=string.Concat("MessageBoxAlert('",txt1.Text,"');";
ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType, "Message",strExample,true);
0
 

Author Comment

by:pointeman
ID: 23635519
That works:

ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "Message", "alert('Success');", true);  
0
 

Author Comment

by:pointeman
ID: 23635690
Q. Do all javascript alert windows look like a small IE window like this code initializes?
ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "Message", "alert('Success');", true);  
 
0
 
LVL 16

Expert Comment

by:burakiewicz
ID: 23635784
i think all javascript alerts look like that. They might vary by browser.  If you want a custom one, you can use the ajax modalpopupextender and create a custom looking one with a panel
0
 

Author Comment

by:pointeman
ID: 23636134
The ASP.NET Ajax Tool Kit?
0
 
LVL 16

Expert Comment

by:burakiewicz
ID: 23636238
yeah, there is a control called the modal popup extender
http://www.asp.net/ajax/ajaxcontroltoolkit/samples/
0
 

Author Comment

by:pointeman
ID: 23638615
Thanks
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question