Home > DeveloperSection > Forums > Visual Web Dev/ASP.net VB Button click
Pravesh Singh
Pravesh Singh

Total Post:101

Points:709
Posted on    June-11-2013 5:00 AM

 VB.Net VB.Net 
Ratings:


 1 Reply(s)
 939  View(s)
Rate this:
Hi Guys

There is a problem with button click event

my line of code as following 

        <asp:Image ID="Image1" runat="server" Height="57px" ImageUrl="~/img/logo.png" 
            Width="36px" />
        <strong>&nbsp;Test</strong> System </h1>
            <form action="" enctype="multipart/form-data" class="pcss3f">
            <header><asp:Label ID="lblOverview" runat="server" Text=""></asp:Label></header>
                <section class="state-normal" style="text-align:center">
                <button type="button" onclick="window.location = 'AddItem.aspx'">Add Work Item</button>
                <button type="button" id="btnMyWork" name="btnMyWork" onclientclick="btnMyWork_Click" runat="server">My Work Items</button>
                <button type="button">Database Stats</button>
                <br>
                </br>
                <asp:Label ID="lblWhoAmI" runat="server" Text=""></asp:Label>
                </section>
<footer><asp:Label ID="lblWhoAmI2" runat="server" Text=""></asp:Label></footer>
    </form>

The button I'm referring to is this:

<button type="button" id="btnMyWork" name="btnMyWork" onclientclick="btnMyWork_Click" runat="server">My Work Items</button>

And here's the VB I'm trying to get it to run:

Protected Sub btnMyWork_Click()
        lblOverview.Text = "Success"
        lblWhoAmI.Text = "Success"
    End Sub

But when I click it, nothing happens. I've tried adding a click handler in the aspx.vb code but the ".click" won't show in the Intelligent.

 Thanks


AVADHESH PATEL

Total Post:604

Points:4228
Posted on    June-12-2013 8:15 AM

Hi Pravesh,

That is a html button. You need to use the ASP button control to fire the OnClick event. Something like below:

<asp:Button id="btnMyWork" onclick="btnMyWork_Click" runat="server" Text="My Work Items" />

Try it and tell us.

Don't want to miss updates? Please click the below button!

Follow MindStick