Solved

Show alert in AJAX UpdatePanel

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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…

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now