removing button1_onclick functions

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
 
M

mark.norgate

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
 
B

bruce barker \(sqlwork.com\)

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top