Reputation: 8404
When my page loads, I have a link to update a record on each record in a repeater control.
The link looks like this when I hover over it with my mouse:
javascript:__doPostBack('ctl00$MainContent$AcctRepeater$ctl03$LinkUpdate','')
I am also using paging on my form. So, when I click this link, it does a postback that recreates the paging.
What I want to do is to check, on page_load, to see if the LinkUpdate link is what is causing the page load. If so, I don't want to process the paging piece.
So, can anyone tell me how to check, on page_load, to see what caused the page load? I tried poking around with the sender piece of protected void Page_Load(object sender, EventArgs e) but couldn't figure it out. Also, e doesn't understand item or CommandName until after the Page_Load piece has completed, so I can't use those either.
Ultimately, what I want to end up with is something like this:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
var MySortVal = cboSortBy.SelectedValue;
var MySortVal2 = Session["SSortBy"];
if (Session["SSortBy"] != null)
{
lblSortOrder.Text = Session["SSortBy"].ToString();
}
else
{
lblSortOrder.Text = "X";
}
Show_Data();
LoadGroups();
}
else if (**this page has been reloaded because of the link**)
{
}
else
{
var MySortVal = cboSortBy.SelectedValue;
var MySortVal2 = Session["SSortBy"];
if (Session["SSortBy"] != null)
{
lblSortOrder.Text = MySortVal;
}
else
{
lblSortOrder.Text = "X";
}
Show_Data();
LoadGroups();
}
}
Upvotes: 0
Views: 43
Reputation: 333
Have you checked this?
Request.Form["__EVENTTARGET"]
It should take the value of the first parameter of __doPostBack which in case of your link should be 'ctl00$MainContent$AcctRepeater$ctl03$LinkUpdate'
Upvotes: 1