Dynamic Link button error when clicked

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Matt

    #1

    Dynamic Link button error when clicked

    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.Attribu tes["param"].Value =
    queryInstanceID .ToString();
    postbackUrl = objNode.Attribu tes["Url"].Value +
    objNode.Attribu tes["param"].Value;
    lnkButton = new LinkButton();
    lnkButton.ID = objNode.Attribu tes["id"].Value;
    lnkButton.Text =
    objNode.Attribu tes["Name"].Value;
    lnkButton.Font. Size = 8;
    lnkButton.Comma ndName = lnkButton.ID.To String();
    lnkButton.Comma ndArgument = postbackUrl;
    lnkButton.Comma nd += new
    CommandEventHan dler(this.lnkBu tton_Click);
    TabHolder.Contr ols.Add(lnkButt on);

    }

    }
    private void lnkButton_Click (object sender, CommandEventArg s e)
    {

    Response.Write( e.CommandName.T oString());
    Response.Write( e.CommandArgume nt.ToString());

    // Response.Redire ct(e.CommandArg ument.ToString( )); // fails after
    come back and click again

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

    }

  • Ben Rush

    #2
    Re: Dynamic Link button error when clicked

    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 EnableViewState Mac="false" %>

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



    "Matt" <metehanIT@Hotm ail.comwrote in message
    news:1175733587 .468342.97490@n 76g2000hsh.goog legroups.com...
    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.Attribu tes["param"].Value =
    queryInstanceID .ToString();
    postbackUrl = objNode.Attribu tes["Url"].Value +
    objNode.Attribu tes["param"].Value;
    lnkButton = new LinkButton();
    lnkButton.ID = objNode.Attribu tes["id"].Value;
    lnkButton.Text =
    objNode.Attribu tes["Name"].Value;
    lnkButton.Font. Size = 8;
    lnkButton.Comma ndName = lnkButton.ID.To String();
    lnkButton.Comma ndArgument = postbackUrl;
    lnkButton.Comma nd += new
    CommandEventHan dler(this.lnkBu tton_Click);
    TabHolder.Contr ols.Add(lnkButt on);
    >
    }
    >
    }
    private void lnkButton_Click (object sender, CommandEventArg s e)
    {
    >
    Response.Write( e.CommandName.T oString());
    Response.Write( e.CommandArgume nt.ToString());
    >
    // Response.Redire ct(e.CommandArg ument.ToString( )); // fails after
    come back and click again
    >
    Server.Execute( e.CommandArgume nt.ToString());
    // Server.Transfer (Session["url"].ToString());
    >
    }
    >

    Comment

    • Matt

      #3
      Re: Dynamic Link button error when clicked

      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.



      Comment

      • John Sun

        #4
        Re: Dynamic Link button error when clicked

        On Apr 4, 9:25 pm, "Matt" <meteha...@Hotm ail.comwrote:
        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.Redire ct instead. This should avoid some post
        back issue.

        HTH.


        Comment

        • Ben Rush

          #5
          Re: Dynamic Link button error when clicked

          Use either Response.Redire ct() (which I would recommend) or use something
          like this in client code:

          Learn how to redirect to another web page using javascript with Tizag.com's Javascript Redirect lesson.


          If you need an example then let me know.

          --
          ~~~~~~~~~~~
          Ben Rush



          "Matt" <metehanIT@Hotm ail.comwrote in message
          news:1175736306 .286516.266030@ b75g2000hsg.goo glegroups.com.. .
          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.
          >
          >
          >

          Comment

          • Matt

            #6
            Re: Dynamic Link button error when clicked

            Response.redire ct 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...

            Comment

            Working...