I created an enhanced Button Control in ASP NET 2.0 to add a delete
confirmation message and to disable the button if the user does not have
access.
The new button control has a "ConfirmMessage " property where you can set the
message you want displayed and a "SecurityKe y" property to set the security
key for the button.
The securitykey works fine. The button is disabled if the user should not
have access to it.
The problem I have is with delete confirmation message. When the user
accepts the confirm message, the click event is fired twice.
If I look at the html source on the client, the button has 2 onclick
statements:
onclick="javasc ript:return confirm('Do you wish to delete this record ?');"
onclick="javasc ript:WebForm_Do PostBackWithOpt ions(new
WebForm_PostBac kOptions(..."
I override the AddAttributesTo Render with the attached code.
If I take out the writer.AddAttri bute(HtmlTextWr iterAttribute.O nclick,
onClickScript) statement, then clicking on the button does nothing
Any help would be appreciated.
Protected Overloads Overrides Sub AddAttributesTo Render(ByVal writer As
HtmlTextWriter)
writer.AddAttri bute(HtmlTextWr iterAttribute.H ref, "#")
Dim onClickScript As String = "javascript :"
Dim actionScript As String = String.Empty
' Do not validate in design mode
If Not Me.DesignMode Then
If Not authorizedAcces s(Me.SecurityKe y.ToString, "E", "B")
Then
Me.Enabled = False
Else
If Me.ShowConfirm Then
actionScript = String.Concat(" return confirm('",
EscapeJavaScrip t(ConfirmMessag e), "');")
End If
End If
End If
If actionScript = String.Empty Then
actionScript =
Me.Page.ClientS cript.GetPostBa ckEventReferenc e(Me, "")
End If
If Me.Enabled AndAlso (Not (Me.Page Is Nothing)) Then
onClickScript += String.Concat(c onfirmScript, actionScript)
writer.AddAttri bute(HtmlTextWr iterAttribute.O nclick,
onClickScript)
End If
If ShowStatusBarTe xt Then
writer.AddAttri bute("onmouseov er",
String.Concat(" javascript:wind ow.status='", EscapeJavaScrip t(StatusBarText ),
"';return true;"))
writer.AddAttri bute("onmouseou t",
"javascript:win dow.status='';r eturn true;")
End If
MyBase.AddAttri butesToRender(w riter)
End Sub
Protected Overridable Function GetClientValida tedPostback(ByV al
control As Control, ByVal confirmScript As String) As String
Dim text1 As String =
control.Page.Cl ientScript.GetP ostBackEventRef erence(control, confirmScript)
Return ("{if (typeof(Page_Cl ientValidate) != 'function' ||
Page_ClientVali date()) " + confirmScript + text1 + "} ")
End Function 0 2337 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Scott Schade |
last post by:
I have a form onto which I add a control during execution. The control is a
control that I wrote. The control has a number of controls on it. I would
like to click on a button on the control and execute a function on the form.
Is this possible?
Thanks,
Scott
|
by: Michael Johnson Jr. |
last post by:
I am trying to handle a button click event, which updates a web control
table with data. The button is dynamically created in the table itself.
When I call updateTable() in the Page_Load the new data from the button is
not available at this time as to allow the table to properly update.
So basically, I need to call UpdateTable() twice, once from page load and
once from button. This causes problems with my application, and I was
trying...
|
by: Oney |
last post by:
I want to open a popup window when user click the web server button
control
When user click the button, only OnClik="OpenWindow(12)" is sent
but no event happend no popup opened.After that, user click again
popup window is open. So user must click twice!
So I must raise event twice. How can I do that or do you advice any
solution?
Thanks!
|
by: Imran Aziz |
last post by:
Hello All,
I have a search text and button that post data and my button handler
filters the repeater control. However when the button is clicked the first
time. The page_load event is being called twice, once with postback true,
and second time without postback. This only happens for this button. How can
I sort out this issue, any clues what to look for to get this sorted please.
<p>Search Bookmarks: <asp:TextBox ID="txtSearch"...
|
by: JohnR |
last post by:
In it's simplest form, assume that I have created a usercontrol,
WSToolBarButton that contains a button. I would like to eventually create
copies of WSToolBarButton dynamically at run time based on some
initialization information obtained elsewhere. Basically, I'm going to
create my own dynamic toolbar where the toolbarbuttons can change. I'm not
using the VB toolbar because of limitations in changing things like
backcolor (I can't get...
| |
by: kai |
last post by:
Hi,
In ASP.NET , what is the difference between OnClick and Click events for a
button? Because we have button click event, it can trigger events, why we
still need OnClick?
Please help.
Thanks
kai
|
by: Demetri |
last post by:
I have created a web control that can be rendered as either a linkbutton or a
button. It is a ConfirmButton control that allows a developer to force a user
to confirm if they intended to click it such as when they do a delete.
Everything is great. By and large it will be used in my repeater controls
using the command event when the user clicks on it and so that event is
working great.
My issue is the Click event. When the control is...
|
by: Chu |
last post by:
Thanks everyone for taking a moment to read this.
I've got a page where I use a LinkButton and I wire up a dynamic event
to the button. When the user clicks the button, the event is fired as
expected. In the event code for that button, a new LinkButton is added
to the page and is wired up to yet a different event, however when
clicked, the page is posted back but the event is not triggered.
I'm assuming it has something to do with the...
|
by: Learner |
last post by:
Hello,
I converted a VS 2003 project to VS 2005. It works perfectly
alright in VS 2003 but when I try running in VS 2005 I got strange
thing going on. The code (my button click event ) runs twice? Has any
one run into this kind of situation before please help. Am I missing
some thing here? or do I need to set an option here?
Thanks,
-L
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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,...
| |
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...
|
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,...
|
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...
|
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...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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...
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |