?
Solved

Show alert in AJAX UpdatePanel

Posted on 2013-01-09
4
Medium Priority
?
514 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
OverviewThis article demonstrates a simple search form using AJAX. The purpose of the article is to demonstrate how to use the same code to render a page and javascript (JQuery) and AJAX to make subsequent calls to refine the results. The princip…
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…
Suggested Courses

741 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