I need to get a CommandArgument from linkbutton inside a userControl
for this pourpose I'm using this code
public partial class userControl_menu : System.Web.UI.UserControl
{
//private string _argument;
public string argument
{
get
{
return ViewState["argument"] == null ?
"Default Value!" :
(string)ViewState["argument"];
}
set { ViewState["argument"] = value; }
}
protected void Page_Init(object sender, EventArgs e)
{
nuovi.Command += new CommandEventHandler(imgClick);
anagrafiche.Command += new CommandEventHandler(imgClick);
catalogo.Command += new CommandEventHandler(imgClick);
}
protected void imgClick(object sender, CommandEventArgs e)
{
argument = e.CommandArgument.ToString();
}
}
but when i'm trying to get the value in the destination page i get "Default Value!"
if i re-click I get the correct value
now, does anyone know what is the correct way to do what I need in the first click?
thank you bye
Marco