473,320 Members | 1,870 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,320 software developers and data experts.

Problems with Attributes.Add("onclick",.... and MyTextBox_TextChanged

Hello,

Controls on webpage:
- Datagrid
- TextBox

Datagrid has Delete button:

<asp:TemplateColumn HeaderText="Borrar">
<HeaderStyle Width="10%"></HeaderStyle>
<ItemStyle HorizontalAlign="Center"></ItemStyle>
<ItemTemplate>
<asp:ImageButton id="btnDelete" runat="server"
CommandName="Delete"></asp:ImageButton>
</ItemTemplate>
</asp:TemplateColumn>

At function MyDatagrid_ItemCreated , I add attributes to that Delete
button. So, when the user click on Delete button, then it's showed a
confirmation message before to proceed to delete the record.

Private Sub MyDatagrid_ItemCreated(ByVal sender As System.Object, ByVal
e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles
MyDatagrid.ItemCreated
If (e.Item.ItemIndex -1) Then
Dim mydeletebutton As TableCell
mydeletebutton = e.Item.Cells(0)
mydeletebutton.Attributes.Add("onclick", "return alert('Are
you sure you will delete record...?');")
End If
End Sub

Now my problem is that the user has to write on the TextBox. When user
focus on the TextBox and then press ENTER, then it is showed windows
message: 'Are you sure you will delete record...?'.
I tried to put hide buttons on the webpage, but no success.
Allways when the user hit ENTER on the TextBox, the message appears on
screen.

This function is never raised:

Private Sub MyTextBox_TextChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyTextBox.TextChanged
' Some code goes here ....
End Sub

How could I solve that?
Thank you!

Nov 17 '06 #1
1 5387
MyTextBox_TextChanged will not fire until postback as this is a server
side event.

when the user is pressing enter, it is firing the clientside onclick
event of the delete button, which is why the alert box is showing.

one thing is that if you don't want it to behave like this, the delete
button should not be receiving focus.. try setting the focus to the
default button you want to react to on enter.

hope this helps

~kcf

On Nov 17, 10:40 am, "Big George" <jbet...@gmail.comwrote:
Hello,

Controls on webpage:
- Datagrid
- TextBox

Datagrid has Delete button:

<asp:TemplateColumn HeaderText="Borrar">
<HeaderStyle Width="10%"></HeaderStyle>
<ItemStyle HorizontalAlign="Center"></ItemStyle>
<ItemTemplate>
<asp:ImageButton id="btnDelete" runat="server"
CommandName="Delete"></asp:ImageButton>
</ItemTemplate>
</asp:TemplateColumn>

At function MyDatagrid_ItemCreated , I add attributes to that Delete
button. So, when the user click on Delete button, then it's showed a
confirmation message before to proceed to delete the record.

Private Sub MyDatagrid_ItemCreated(ByVal sender As System.Object, ByVal
e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles
MyDatagrid.ItemCreated
If (e.Item.ItemIndex -1) Then
Dim mydeletebutton As TableCell
mydeletebutton = e.Item.Cells(0)
mydeletebutton.Attributes.Add("onclick", "return alert('Are
you sure you will delete record...?');")
End If
End Sub

Now my problem is that the user has to write on the TextBox. When user
focus on the TextBox and then press ENTER, then it is showed windows
message: 'Are you sure you will delete record...?'.
I tried to put hide buttons on the webpage, but no success.
Allways when the user hit ENTER on the TextBox, the message appears on
screen.

This function is never raised:

Private Sub MyTextBox_TextChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyTextBox.TextChanged
' Some code goes here ....
End Sub

How could I solve that?
Thank you!
Nov 17 '06 #2

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

Similar topics

2
by: Eric Smith | last post by:
I'm writing a DTD for a simulator to save the state of the simulated machine, such as register and memory contents. In this particular application, it is not expected that the generated XML will...
17
by: Colin Cogle | last post by:
------- Line 47, column 8: there is no attribute "id" <DIV id="LeftNavigation" style="position:absolute; left:8px; top:6px; width:200p ------- Line 47, column 31: there is no attribute "style"...
8
by: nicolas.sanguinetti | last post by:
Hi, I want to add custom attributes to my xhtml documents to use with my DOM scripts. For example, I want to have some tags -say, the <h1>- have an attribute and a . The thing is that I also...
16
by: Bret Pehrson | last post by:
I've converted a non-trivial C++ library to managed, and get the following unhelpful linker error: Assignment.obj : error LNK2022: metadata operation failed (80131195) : Custom attributes are...
2
by: Brian | last post by:
NOTE ALSO POSTED IN microsoft.public.dotnet.framework.aspnet.buildingcontrols I have solved most of my Server Control Collection property issues. I wrote an HTML page that describes all of the...
6
by: Samuel M. Smith | last post by:
I have been playing around with a subclass of dict wrt a recipe for setting dict items using attribute syntax. The dict class has some read only attributes that generate an exception if I try to...
3
by: sagar | last post by:
Hello everyone, I am developing a AJAX based IM application. I use javascript to dynamically generated small windows using nested <div> within the web-page. I use the following ways to set...
11
by: Nathan Sokalski | last post by:
I add several JavaScript events (onchange, onkeypress, etc.) to Controls using the Add method of the Attributes collection. However, if the JavaScript code contains certain characters, such as & or...
11
by: Rafe | last post by:
Hi, I'm working within an application (making a lot of wrappers), but the application is not case sensitive. For example, Typing obj.name, obj.Name, or even object.naMe is all fine (as far as...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.