Here we can use use CommandName
property, by passing URL
in every button's CommandName
property and passing it as a parameter to your Common Method
to fetch data , So you can create a single function and call it through you btn_Click
event .
<asp:Button ID="button1" runat="server" Text="clickMe"
CommandName="put your URL here" OnCommand="button1_Click" />
<%--OnClick="button1_Click" />--%>
See here we can pass your 'URL' in CommandName
property ,few things to keep in mind , Here we are using OnCommand
event rather than OnClick
event of button , so that we can use 'CommandName' property here .1. OnCommand MSDN
2. Commandname MSDN
// private void button1_Click(object sender, EventArgs e)
private void button1_Click(object sender, CommandEventArgs e)
{
string sourceUrl = Convert.tostring(e.CommandName)
// Call function to grab data pass URL as parameter.
GrabDate (sourceUrl ) ;
So now we can get the URL
value from button CommandName
property .
3 . EventArgs Class
4 .CommandEventArgsClass