472,780 Members | 1,717 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,780 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 5352
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: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.