Solved

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

Posted on 2006-07-19
5
639 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

749 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