PC Review


Reply
Thread Tools Rating: Thread Rating: 1 votes, 1.00 average.

Button OnClick not firing on first click

 
 
SAL
Guest
Posts: n/a
 
      29th May 2007
Hello,
I have a button on a webform that has an OnClick event defined as such:

<asp:Button ID="btnSearchByName" runat="server" Text="Search By Name"
OnClick="btnSearchByName_Click" Width="152px" EnableViewState="False"
CausesValidation="False" />

the btnSearchByName_Click event fires the second time the button is clicked
but not the first. Is there something I'm missing on getting the thing to
fire the first time it's clicked instead of the second time?

Thanks
S


 
Reply With Quote
 
 
 
 
Alexey Smirnov
Guest
Posts: n/a
 
      29th May 2007
On May 29, 8:07 pm, "SAL" <S...@NoNo.com> wrote:
> Hello,
> I have a button on a webform that has an OnClick event defined as such:
>
> <asp:Button ID="btnSearchByName" runat="server" Text="Search By Name"
> OnClick="btnSearchByName_Click" Width="152px" EnableViewState="False"
> CausesValidation="False" />
>
> the btnSearchByName_Click event fires the second time the button is clicked
> but not the first. Is there something I'm missing on getting the thing to
> fire the first time it's clicked instead of the second time?
>


what's the code of btnSearchByName_Click?

 
Reply With Quote
 
SAL
Guest
Posts: n/a
 
      29th May 2007
Public Sub btnSearchByName_Click(ByVal sender As Object, ByVal e As
System.EventArgs)
Dim abll As New AnnexationsBLL
If Not txtSearchByName Is Nothing Then
gvAnnexations.DataSource =
abll.GetAnnexationsByName(txtSearchByName.Text)
gvAnnexations.DataSourceID = Nothing
gvAnnexations.DataBind()
End If
End Sub

However, it doesn't even break into this routine on the first click
(breakpoint is on the If statement). What the heck? Sometimes it works and
sometimes it doesn't. Is this some kind of ASP.NET (2.0) bug or something?

S

"Alexey Smirnov" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> On May 29, 8:07 pm, "SAL" <S...@NoNo.com> wrote:
>> Hello,
>> I have a button on a webform that has an OnClick event defined as such:
>>
>> <asp:Button ID="btnSearchByName" runat="server" Text="Search By Name"
>> OnClick="btnSearchByName_Click" Width="152px" EnableViewState="False"
>> CausesValidation="False" />
>>
>> the btnSearchByName_Click event fires the second time the button is
>> clicked
>> but not the first. Is there something I'm missing on getting the thing to
>> fire the first time it's clicked instead of the second time?
>>

>
> what's the code of btnSearchByName_Click?
>



 
Reply With Quote
 
Alexey Smirnov
Guest
Posts: n/a
 
      29th May 2007
On May 29, 9:12 pm, "SAL" <S...@NoNo.com> wrote:
> Public Sub btnSearchByName_Click(ByVal sender As Object, ByVal e As
> System.EventArgs)
> Dim abll As New AnnexationsBLL
> If Not txtSearchByName Is Nothing Then
> gvAnnexations.DataSource =
> abll.GetAnnexationsByName(txtSearchByName.Text)
> gvAnnexations.DataSourceID = Nothing
> gvAnnexations.DataBind()
> End If
> End Sub
>
> However, it doesn't even break into this routine on the first click
> (breakpoint is on the If statement). What the heck? Sometimes it works and
> sometimes it doesn't. Is this some kind of ASP.NET (2.0) bug or something?
>


hmm, try to set EnableViewState to true, maybe this can change that?


 
Reply With Quote
 
SAL
Guest
Posts: n/a
 
      29th May 2007
Yep, already tried that and it doesn't seem to have any effect.

S

"Alexey Smirnov" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> On May 29, 9:12 pm, "SAL" <S...@NoNo.com> wrote:
>> Public Sub btnSearchByName_Click(ByVal sender As Object, ByVal e As
>> System.EventArgs)
>> Dim abll As New AnnexationsBLL
>> If Not txtSearchByName Is Nothing Then
>> gvAnnexations.DataSource =
>> abll.GetAnnexationsByName(txtSearchByName.Text)
>> gvAnnexations.DataSourceID = Nothing
>> gvAnnexations.DataBind()
>> End If
>> End Sub
>>
>> However, it doesn't even break into this routine on the first click
>> (breakpoint is on the If statement). What the heck? Sometimes it works
>> and
>> sometimes it doesn't. Is this some kind of ASP.NET (2.0) bug or
>> something?
>>

>
> hmm, try to set EnableViewState to true, maybe this can change that?
>
>



 
Reply With Quote
 
Alexey Smirnov
Guest
Posts: n/a
 
      29th May 2007
On May 29, 9:25 pm, "SAL" <S...@NoNo.com> wrote:
> Yep, already tried that and it doesn't seem to have any effect.
>


Well, I don't see any error here. I think you have a validation
controls and/or a client script that makes this strange effect. If you
cannot find an error, send a full code of your webform, I will try to
look into it.


 
Reply With Quote
 
SAL
Guest
Posts: n/a
 
      30th May 2007
Alexey,
if you are still listening to this thread,
I've found an interesting effect. If I tab out of the text box, the field
that is used to limit results by the button click event, the page refreshes
and in that circumstance, the button click event fires and limits the
results on the first click. I don't really get why this is happening.
This page that we've been discussing is using a master page, if that
matters, and I set the AutoEventWireup to true prior to this little effect.

S

"Alexey Smirnov" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> On May 29, 9:25 pm, "SAL" <S...@NoNo.com> wrote:
>> Yep, already tried that and it doesn't seem to have any effect.
>>

>
> Well, I don't see any error here. I think you have a validation
> controls and/or a client script that makes this strange effect. If you
> cannot find an error, send a full code of your webform, I will try to
> look into it.
>
>



 
Reply With Quote
 
Alexey Smirnov
Guest
Posts: n/a
 
      30th May 2007
On May 30, 7:29 pm, "SAL" <S...@NoNo.com> wrote:
> Alexey,
> if you are still listening to this thread,
> I've found an interesting effect. If I tab out of the text box, the field
> that is used to limit results by the button click event, the page refreshes
> and in that circumstance, the button click event fires and limits the
> results on the first click. I don't really get why this is happening.
> This page that we've been discussing is using a master page, if that
> matters, and I set the AutoEventWireup to true prior to this little effect.


Try make a copy of the form, remove all controls except the one which
failed and see if it helps. There is something that affects on it.

 
Reply With Quote
 
SAL
Guest
Posts: n/a
 
      30th May 2007
Well, I did that and it seems to be working as expected now. I had a label
control on the page with an ID="lblSearchByName"
and the textbox's ID="txtSearchByName"
It's hard to believe it would get confused by this but maybe.

So now, the textbox is behaving more as one would expect. When I start to
type in a name, it shows previously typed in names that begin with the
letters I'm typing. It wasn't doing that before. Also, when I tab out of the
textbox, the page does not refresh as it should not.

Thank you very much for your help.
S

"Alexey Smirnov" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> On May 30, 7:29 pm, "SAL" <S...@NoNo.com> wrote:
>> Alexey,
>> if you are still listening to this thread,
>> I've found an interesting effect. If I tab out of the text box, the field
>> that is used to limit results by the button click event, the page
>> refreshes
>> and in that circumstance, the button click event fires and limits the
>> results on the first click. I don't really get why this is happening.
>> This page that we've been discussing is using a master page, if that
>> matters, and I set the AutoEventWireup to true prior to this little
>> effect.

>
> Try make a copy of the form, remove all controls except the one which
> failed and see if it helps. There is something that affects on it.
>



 
Reply With Quote
 
kinh.bui@getauto.com
Guest
Posts: n/a
 
      19th Jul 2007
On May 30, 3:01 pm, "SAL" <S...@NoNo.com> wrote:
> Well, I did that and it seems to be working as expected now. I had a label
> control on the page with an ID="lblSearchByName"
> and the textbox's ID="txtSearchByName"
> It's hard to believe it would get confused by this but maybe.
>
> So now, the textbox is behaving more as one would expect. When I start to
> type in a name, it shows previously typed in names that begin with the
> letters I'm typing. It wasn't doing that before. Also, when I tab out of the
> textbox, the page does not refresh as it should not.
>
> Thank you very much for your help.
> S
>
> "Alexey Smirnov" <alexey.smir...@gmail.com> wrote in message
>
> news:(E-Mail Removed)...
>
> > On May 30, 7:29 pm, "SAL" <S...@NoNo.com> wrote:
> >> Alexey,
> >> if you are still listening to this thread,
> >> I've found an interesting effect. If I tab out of the text box, the field
> >> that is used to limit results by thebuttonclickevent, the page
> >> refreshes
> >> and in that circumstance, thebuttonclickevent fires and limits the
> >> results on thefirstclick. I don't really get why this is happening.
> >> This page that we've been discussing is using a master page, if that
> >> matters, and I set the AutoEventWireup to true prior to this little
> >> effect.

>
> > Try make a copy of the form, remove all controls except the one which
> > failed and see if it helps. There is something that affects on it.


Hi guys,
I have the same issue here where the link button only fires after the
sencond click. I try to follow you guys reply above and not sure if I
follow you guys. can you guys help me out again by stepping me
through?
Any help is greatly appreciated

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
asp:Button not firing on first click when in PopupControlExtender mazdotnet Microsoft ASP .NET 1 2nd Oct 2008 02:31 PM
asp.net dynamically created button not firing onClick event rsaffy@nuvox.com Microsoft ASP .NET 7 20th Jul 2006 10:02 PM
button server onclick not firing Vikram Microsoft ASP .NET 3 2nd Feb 2006 11:35 PM
Button Click events only firing on second click Ben Fidge Microsoft ASP .NET 5 15th Jun 2004 03:28 PM
Button OnClick event not firing Daisy Microsoft C# .NET 4 18th Jan 2004 04:23 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:45 PM.