473,788 Members | 2,735 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

alert box in asp.net

How can we use alert and confirm method in asp.net application.

i am working with application where i want to use confirm box before
going for any operation. and same for alert box

Sonu

Nov 17 '05 #1
4 10389
have a look at this:

http://www.binaryshift.com/DisplayPo...ick/Index.aspx

HTH

Ollie Riches

"sonu" <kr*******@yaho o.com> wrote in message
news:11******** **************@ g43g2000cwa.goo glegroups.com.. .
How can we use alert and confirm method in asp.net application.

i am working with application where i want to use confirm box before
going for any operation. and same for alert box

Sonu

Nov 17 '05 #2
On 19 Sep 2005 09:30:14 -0700, "sonu" <kr*******@yaho o.com> wrote:
How can we use alert and confirm method in asp.net application.

i am working with application where i want to use confirm box before
going for any operation. and same for alert box

Sonu


Dealing with popup windows can be tricky and not safe (popup blockers
may negate your efforts.)

The easiest way would be to employ the "confirm" statement in
client-side javascript.

For example, consider the most common case - adding a confirmation
dialog when user attempts to delete a record from a datagrid (gridList
below) on ASP.NET page. The server-side event handler will only
execute if the user clicks "yes" on the client-side, causing the event
to fire:

In your HTML:

<asp:TemplateCo lumn>
<ItemTemplate >
<asp:LinkButt on id="linkDelete " runat="server"
CommandName="De lete">Delete</asp:LinkButton>
</ItemTemplate>
</asp:TemplateCol umn>
In your code behind:

// The below will add a confirmation dialog
// to each linkDelete instance at runtime
private void gridList_ItemDa taBound(object sender,
DataGridItemEve ntArgs e )
{
if( e.Item.FindCont rol("linkDelete ") !+ null )
{
LinkButton deleteButton =
e.Item.FindCont rol("linkDelete ") as LinkButton;

deleteButton.At tributes.Add( "onclick",
@"javascript:re turn confirm('Are you sure you want to delete this
record?');" )

}
}

private void gridList_Delete Command( object source,
DataGridCommand EventArgs e )
{
// Delete the record here
}
Nov 17 '05 #3
this is in asp.net and language is vb
Public Shared Sub Alert(ByRef aspxPage As System.Web.UI.P age, ByVal
strMessage As String)
Dim strScript As String = "<script language=JavaSc ript>alert('" &
strMessage & "')</script>"
If (Not aspxPage.IsStar tupScriptRegist ered("strKey1") ) Then
aspxPage.Regist erStartupScript ("strKey1", strScript)
End If
End Sub

the above function is a public shared function which accepts page in which
alert is required and second param is of the message which you want to
dispaly.....
if u write this function in a class then call the class.function name with
params that should work.

For example if i wirte above code in "uitl .class"
then while calling i have to from webform as util.Alert(me, "Hello World")

"sonu" wrote:
How can we use alert and confirm method in asp.net application.

i am working with application where i want to use confirm box before
going for any operation. and same for alert box

Sonu

Nov 17 '05 #4
for confirm box

Public Shared Sub Confirm(ByRef btn As WebControls.But ton, ByVal strMessage
As String)
btn.Attributes. Add("onclick", "return confirm('" & strMessage & "');")
End Sub

write this code in a static class called util
in webform load you have to map the particular event to this confirm box
with the following systax
Me.button.Attri butes.Add("oncl ick", "return confirm('Your message goes
here');")

this above code should work, further quires feel free to contact
na************@ hotmail.com

"sonu" wrote:
How can we use alert and confirm method in asp.net application.

i am working with application where i want to use confirm box before
going for any operation. and same for alert box

Sonu

Nov 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
3222
by: optimistx | last post by:
How to write a function f(x) or f('x') so that it produces the same output as a call to alert-function: var x='abc'; alert('x='+x); In testing one needs to write similar alert() calls often. By having a function f(), which would add the variable name in front of the variable value one would save a lot of typing during one's lifetime.
2
16863
by: schieco | last post by:
The following code always prints the debug lines inside the conditional if statement before and after the alert statement when the session has timed out, but the alert and redirect only appear/work in certain situations. <% // Check for expired session log.debug("session ID = " + session.getAttribute("session_loginID")); if (session.getAttribute("session_loginID") == null)
4
4020
by: hugo2 | last post by:
Most of these characters are not on the standard keyboard. Here's a successful contrivance, with comments & cautions, a little page that works in IE6. <HTML><HEAD><SCRIPT TYPE="text/javascript"> function alt() { document.all.s1.innerHTML="Current Temp: 68°F"; var txt=document.all.s1.innerText; alert(txt); }
11
4589
by: Alistair Saldanha | last post by:
I'm looking for the event that is fired by Internet Explorer to an "alert": <SCRIPT> Alert("You already have a session open") </SCRIPT> The event would be webBrowser.Document.???? Much appreciate any help you can give me. Thanks,
0
1680
by: Stephanie | last post by:
I have a problem with an Alert that is supposed to invoke a Job. Here are some details: Windows Server 2000 SQL Server Standard Ed. ver. 8.00.818 (Sp3) Alert: SQL Server performance condition alert; Counter: Percent Log Used; If the counter rises above 90% the response is to execute Job. Job: Transaction Log backup; set up through the Database Maintenance Plans. This job runs a backup hourly during the day, on a couple of the...
3
9715
by: umdsasha | last post by:
So, basically, I need to detect whether an alert window was thrown. I can't find where it's thrown from but I need to disable a button only if there were no alert windows thrown. Any ideas? Thanks Alex
4
4034
by: joe | last post by:
Hi, I defined: <div id="abc"> </div> in my .html file, after an Ajax query my weberserver sends: <script language="JavaScript"> alert('Hello World!"); </script>
5
6303
by: vjsv2007 | last post by:
Can you help to make one alert with all details? <script type="text/javascript"> <!-- function validate_form ( ) { valid = true;
24
8228
by: Jeremy J Starcher | last post by:
While reading c.l.j, I've noticed that some people prefer and indeed even recommend the use of "window.alert()" over "alert()". I can't find any technical reason to make this distinction, and seems to have a (tiny) amount overhead since window itself points to the global object, hence, a circular reference. (From everything I am reading, window is just a REFERENCE back to the global object, as opposed to a separate object.)
0
9498
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10373
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10177
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10118
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9969
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7519
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5403
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5538
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3677
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.