473,385 Members | 2,014 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How to show an alert message box for a button in update panel?

40
Hi,

I have a webform all the controls are in a update panel,i have to write a script for showing error messages in a popup.

These are the scripts i tried

Expand|Select|Wrap|Line Numbers
  1. 1.private void MessageBox(string message)
  2.     {
  3.  
  4.         string tmp = "";
  5.         tmp = "<script language='javascript'>";
  6.         tmp += "alert('" + message + "');";
  7.         tmp += "</script>";
  8.         Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "MyScript", tmp);
  9.     }
  10.  
  11. 2. private void MessageBox(string message)
  12.     {
  13.       if (!string.IsNullOrEmpty(message))
  14.        {
  15.             Response.Write("<script  type=\"text/javascript\" language=\"javascript\">");
  16.             Response.Write("alert('" + message + "');");
  17.        Response.Write("</script>");
  18.         }
  19.      }

these scripts work fine if the button is outside the update panel. I want scripts for displaying on a click of button which is inside update panel.Please reply asap.

Thanks in advance,
Blacky
Nov 1 '10 #1
2 11513
Frinavale
9,735 Expert Mod 8TB
When you are using UpdatePanels and JavaScript needs to be called, you must register the JavaScript with the ScriptManager. There are several methods available to let you register your JavaScript with the ScriptManager, so be sure to read the descriptions of each of them to choose the one best suited for your case.

-Frinny
Nov 1 '10 #2
Hi Buddy,

below code may help to fix your problem.

Expand|Select|Wrap|Line Numbers
  1. ScriptManager.RegisterClientScriptBlock(Me, Page.GetType, "Validation", "function name", True)
Nov 2 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Ipsita | last post by:
Hi, I am explaining the scenario of what I am trying to do: - I have a webform with some controls, from which I am taking the data. eg say Username, password - I am passing these data as...
2
by: rodchar | last post by:
hey all, i saw an update panel example one time where they put a button outside the update panel and a textbox inside the panel and setup a trigger on the update panel to update when the button...
2
by: Giridhara | last post by:
hi can any one help me in a text field im featching value from database,if i change the value in same i need to show alert msg
1
by: gabe | last post by:
How do you call a client side javascript callback method after an update panel has posted back to the server? I have two update panels (A + B) with a gridview in each panel. GridView B has a...
1
by: durga2005 | last post by:
hi i have a textbox and regular expression validator control .i have placed these control inside update panel. just im validating the textbox with regular expression validator control when i...
0
by: nityaprashant | last post by:
hello.. i used ajax update panel in my cart form now i want to use paypal button for redirect online transaction because of ajax update panel round trip is not possible.. so paypal button gives...
2
by: =?Utf-8?B?TUNN?= | last post by:
I have an asp.net page that contains an update panel. Within the update panel, controls get added dynamically. During partial page post backs the controls within the panel will change. I have a...
1
by: altafbytes | last post by:
I have created Messagebox as usercontrol, in messagebox therer is one Html button. I am trying to show messagebox it working outside of updatepanel , html button not displaying in update...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.