There are a few ways to link an event to a button.
1. You can specify in the ASP:Button tag an OnClick that
has a method. This will require that you know the
parameters of the method Object o, System.EventArgs e
2. double click on the button in design view. This is
for those who are either 1 lazy and looking for a
shortcut, or 2 don't know how the programming language
uses Methods. This method will create the shell of a
function for you with the parameters and draw the mapping
between the button and the event method. This method
does not always work depending on how technical your page
is and if you have your button nested in a grid, etc.
3. (this if for the VB developers) Create a button in
HTML, Create a Method in the code. After the method
declaration, append Handles buttonname.click
4. (this is for the C# developers) Create a button in
the HTML, Create your method with the appropriate
parameters. Go to the System Generated code
InitializeCompontent section and create your Delegate
method reference. For example...
this.btnCancel.Click += new System.EventHandler
(this.btnCancel_Click);
If you realy want to understand what is going on, you
should use either option 3 or option 4. It will make you
a better programmer in the long run.
Good Luck,
Keith
>-----Original Message-----
>I'm having a bit of trouble understanding how to get an
>asp.net page to look and feel like the asp page I have
>already created. It's a basic login page, which I have
>attempted to create in the vs html editor as so (just
the
>form code):
>
><form id="Form1" method="post" runat="server">
>
><asp:table id="Table1" runat="server"
>HorizontalAlign="Center" CssClass="LogInHead"
>Width="300px">
>
><asp:TableRow CssClass="LogIn">
><asp:TableCell Text="Log In to EPES"></asp:TableCell>
></asp:TableRow>
>
></asp:table>
>
><asp:table id="Table2" HorizontalAlign="Center"
>CssClass="LogInBody" Width="300px" Runat="server">
>
><asp:TableRow>
><asp:TableCell CssClass="LogInDesc" Text="User
>ID:"></asp:TableCell>
><asp:TableCell CssClass="LogInCtrl">
><asp:TextBox ID="txtUID" runat="server" Width="150px"
>MaxLength="20" />
></asp:TableCell>
></asp:TableRow>
>
><asp:TableRow>
><asp:TableCell CssClass="LogInDesc"
>Text="Password:"></asp:TableCell>
><asp:TableCell CssClass="LogInCtrl">
><asp:TextBox ID="txtPassword" Runat="server"
>Width="150px" MaxLength="20" TextMode="Password" />
></asp:TableCell>
></asp:TableRow>
>
><asp:TableRow>
><asp:TableCell>
><asp:Button ID="btnSubmit" Runat="server" Text="Log
In" />
></asp:TableCell>
></asp:TableRow>
></asp:table>
></form>
>
>I have tried to drag a button on to the table control in
>the designer (which didn't work). The method I have
used
>above displays the page the way I want it to, but I
can't
>seem to find a way to link the controls (specifically
the
>button) to a server-side event.
>
>Any help (or any links) would be greatly appreciated.
>
>Paul K
>.
>
|