Solved

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

Posted on 2006-07-19
5
628 Views
Last Modified: 2008-01-09
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
Comment
Question by:JoeUS
  • 3
  • 2
5 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 17141569
>>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
 

Author Comment

by:JoeUS
ID: 17141776

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
 
LVL 96

Accepted Solution

by:
Bob Learned earned 500 total points
ID: 17141966
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
 

Author Comment

by:JoeUS
ID: 17149381
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
 
LVL 96

Expert Comment

by:Bob Learned
ID: 17160370
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now