Dynamic Link button error when clicked

M

Matt

Creating Dynamic aspnet link buttons with in user control, Then i use
the control on ever page with wraped with master page. I get the url
of the link buttons from xml. Parameter from xml also Builing
Dynamicly link buttons with url's works fine. The problem is when i
click the buttons they First link button and second link button works
third fails and also when i came back and click the first one that
dont work either, page gives " The state information is invalid for
this page and might be corrupted. " Can any one Help..

Here is the Code behind for the MenuTab.asxc which get implemented by
my aspx page..


foreach (XmlNode objNode in objNodesLst)
{

objNode.Attributes["param"].Value =
queryInstanceID.ToString();
postbackUrl = objNode.Attributes["Url"].Value +
objNode.Attributes["param"].Value;
lnkButton = new LinkButton();
lnkButton.ID = objNode.Attributes["id"].Value;
lnkButton.Text =
objNode.Attributes["Name"].Value;
lnkButton.Font.Size = 8;
lnkButton.CommandName = lnkButton.ID.ToString();
lnkButton.CommandArgument = postbackUrl;
lnkButton.Command += new
CommandEventHandler(this.lnkButton_Click);
TabHolder.Controls.Add(lnkButton);

}

}
private void lnkButton_Click(object sender, CommandEventArgs e)
{

Response.Write(e.CommandName.ToString());
Response.Write(e.CommandArgument.ToString());

// Response.Redirect(e.CommandArgument.ToString()); // fails after
come back and click again

Server.Execute(e.CommandArgument.ToString());
// Server.Transfer(Session["url"].ToString());

}
 
B

Ben Rush

Hrm, I'm not completely sure I follow everything that you're doing. But, one
thing you might want to try (since I see a Server.Execute and commented
Server.Transfer in your code) is adding this to your page:

<%@ Page EnableViewStateMac="false" %>

If this does not help, google things like "viewstate server.execute", etc.
and see what pops up.
 
M

Matt

Though I get rid of Server transer, i Still get the error.
I just would like to create link buttons dynamicly which i do and Send
them to the Click event or and to to that page
which has the same control so i can click another link button.
But it fails after two attempt.
Guys, Any other suggestion to navigate my link buttons url's when its
clicked. Server transfer or execute or direct does not work for me.
 
J

John Sun

Though I get rid of Server transer, i Still get the error.
I just would like to create link buttons dynamicly which i do and Send
them to the Click event or and to to that page
which has the same control so i can click another link button.
But it fails after two attempt.
Guys, Any other suggestion to navigate my link buttons url's when its
clicked. Server transfer or execute or direct does not work for me.

I would try Response.Redirect instead. This should avoid some post
back issue.

HTH.
 
M

Matt

Response.redirect fails
First time page comes up, Controls gets creaeted with 3 link button. I
click on first works, then second works, I go clickon the first link
button again I get
" The state information is invalid for this page and might be
corrupted. " error, Click on second again same error..
how to stop this guys...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top