|
|
 |
 |
 |
 |
Button OnClick not firing on first click
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
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-----------------------------------------------
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" <alexey.smir @gmail.com> wrote in message news:1180465226.013382.12720@g37g2000prf.googlegroups.com...
> 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?
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-----------------------------------------------
Yep, already tried that and it doesn't seem to have any effect. S "Alexey Smirnov" <alexey.smir @gmail.com> wrote in message news:1180466400.565392.3370@j4g2000prf.googlegroups.com...
> 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?
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-----------------------------------------------
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" <alexey.smir @gmail.com> wrote in message news:1180468606.358320.308340@q66g2000hsg.googlegroups.com...
> 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.
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-----------------------------------------------
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:1180547906.487608.158950@g4g2000hsf.googlegroups.com...
> 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.
|
 |
 |
 |
 |
|