?
Solved

Show alert in AJAX UpdatePanel

Posted on 2013-01-09
4
Medium Priority
?
531 Views
Last Modified: 2013-01-10
Dear experts

I’m relative new to ASPX and AJAX. I have a CollapsiblePanelExtender, an UpdatePanel and ModalPopupExtender . I I need to show a alert message. How to do it with this code?

I try with code like:
                CustomMessage = "Unexpected error in del record " + sErr;
                Page.ClientScript.RegisterStartupScript(this.GetType(), "errmsg", "<script>alert('" + CustomMessage + "');</script>;");

But it not work, the message is not shown. The problem is that the message should consits sErr which is code generated. How to do it? Also, the messages are 10, there a lot of logical check before do the logic with Save button.


Except a message , un acceptable option is to write the error in a textbox or label, is this possible?
Untitled.jpg
Untitled1.jpg
0
Comment
Question by:dvplayltd
  • 2
  • 2
4 Comments
 
LVL 18

Accepted Solution

by:
Rajar Ahmed earned 2000 total points
ID: 38761908
Try this,

<script>
function displayMessage(msg){
alert(msg);
}
</script>

Open in new window


string sErr ="test";
string custommessage = "Unexpected error in del record " + sErr;
ScriptManager.RegisterStartupScript(this.Page,this.GetType(),"scriptName","displayMessage('" + custommessage + "');",true);

Open in new window

0
 

Author Comment

by:dvplayltd
ID: 38761947
Hyyym.

I got your idea, but is it possible to have a solution which do not require additional defined error ? Will be better to show and unxpected error raised.
0
 
LVL 18

Expert Comment

by:Rajar Ahmed
ID: 38761969
sorry i dint get you ,

My code invokes the the javascript function from code behind.

can u provide a code which can demonstrate your problem
0
 

Author Closing Comment

by:dvplayltd
ID: 38762053
10x. A professional answer-thank you. I do copy/paste and it work! Sorry for my prevous post-please ignore it.
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

There is a wide range of advantages associated with the use of ASP.NET. This is why this programming framework is used to create excellent enterprise-class websites, technologies, and web applications.
An ASP.NET Web Form User Control is not newly introduced in ASP.NET. In fact, it was an old technology yet still playing a role to generate web content, especially when we want to use it to have a better and easy way to control part of the web conte…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

590 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