Solved

Show alert in AJAX UpdatePanel

Posted on 2013-01-09
4
506 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 500 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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

jQuery is a JavaScript library that greatly simplifies JavaScript programming. AJAX is an acronym formed from "Asynchronous JavaScript and XML."  AJAX refers to any communication between client and server, when the human client does not observe a…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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…

737 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