[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 683
  • Last Modified:

System.Web.UI.WebControls.CommandEventHandler(LinkButton_Command)

ASP.NET , C#
I have the following event handler set in a LinkButton control, which I placed into Page_Load.
I want to use the CommandEventHandler(LinkButton_Command) value after PostBack back in
Page_Load to filter a query, which eventually updates the same lbtn property. Needless to say,
I can't seem to be able to get the  CommandEventHandler(LinkButton_Command) value back into Page_Load.
                   
lbtn.CommandArgument = i.ToString();
                   
lbtn.Command += new System.Web.UI.WebControls.CommandEventHandler(LinkButton_Command);
0
JoeUS
Asked:
JoeUS
  • 3
  • 2
1 Solution
 
Bob LearnedCommented:
>>I can't seem to be able to get the  CommandEventHandler(LinkButton_Command) value back into Page_Load.
That doesn't make any sense.  The value of what?

Bob
0
 
JoeUSAuthor Commented:

CommandEventHandler(LinkButton_Command)
calls the following method      
protected void LinkButton_Command(Object sender, CommandEventArgs e)
and in this method
e.CommandArgument holds the value of  lbtn.CommandArgument = i.ToString()

now here I make a
public string lbtnValue = e.CommandArgument;
but get nothing in lbtnValue in Load_page

I hope it helps
0
 
Bob LearnedCommented:
This is the order of things:

1) Click on a LinkButton control
2) An post-back occurs
3) The Page_Load event is fire
4) The LinkButton_Command event is handled

As you can see, you can't get the value from Page_Load, because it hasn't happened yet.

Bob
0
 
JoeUSAuthor Commented:
so,
what is your suggestion to solve this problem.
I tried to set the value into a session var, label, text in the method they don't show up in Page_Load only after the second post-back.
Generally, how do get the LinkButton_Command event value back in one trip if I dynamically create a control and place it into Page_Load?
0
 
Bob LearnedCommented:
Can you describe the bigger picture and what you need to accomplish, so that I could recommend the "best" course of action, please?

Bob
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now