removing button1_onclick functions

  • Thread starter Thread starter adrianca
  • Start date Start date
A

adrianca

Hi All,
Is there any way to execute a page object function without
going to the code behind.
Eg:
<asp:Button ID="Button1" runat="server" Text="Save Page"
OnClick="<%SQLDataSource1.Insert()%>" />
instead of
<asp:Button ID="Button1" runat="server" Text="Save Page"
OnClick="Button1_Click" />

protected void Button1_Click(object sender, EventArgs e)
{
SQLDataSource1.Insert();

}

Is there any eval metheod <%# % > <%$ % > etc.. to run the method in
the page.

thanks
slyi
 
Don't think so.

An option might be to have the code in the markup file though, if you
want to avoid code-behind.

Mark
 
sure, use a script block;

<asp:Button ID="Button1"
runat="server"
Text="Save Page"
OnClick="Button1_Click" />
<script runat="server">
protected void Button1_Click(object sender, EventArgs e)
{
SQLDataSource1.Insert();
}
</script>

-- bruce (sqlwork.com)
 
Back
Top