Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 528
  • Last Modified:

Show alert in AJAX UpdatePanel

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
dvplayltd
Asked:
dvplayltd
  • 2
  • 2
1 Solution
 
Rajar AhmedConsultantCommented:
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
 
dvplayltdAuthor Commented:
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
 
Rajar AhmedConsultantCommented:
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
 
dvplayltdAuthor Commented:
10x. A professional answer-thank you. I do copy/paste and it work! Sorry for my prevous post-please ignore it.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now