locked
Having an issue with passing the text of a link to a session variable. RRS feed

  • Question

  • I am having an issue with passing the text from a link to a session variable. I am adding this html as a literal for each item in the list that i have populated with a query.

    List<Literal> lit = new List<Literal>();
                for (int i = 0; i < posts.Count; i+=4)
                {
    
                    Literal someLit = new Literal();
                    someLit.Text= 
              @"<div class='row'>" +
    
                "<div class='col-md-12'>" +
    
                  "<div class='panel'>" +
                   " <div class='panel-body'>" +
    
    
                     " <!--/stories-->" +
    
    
                     " <div class='row'>   " +
                       " <br>" +
                        "<div class='col-md-2 col-sm-3 text-center' id='javascript'> <h3>" +
                        " <a href='#' runat='server'  onserverclick='UserProfile_Click'>" + posts[i + 3] + " </a>" +
                        "</h3>" +
                       " </div>" +
    
                                  "  <div class='col-md-10 col-sm-9'>" +
                                     "<h3><a href='Thread.aspx' runat='server' onserverclick='MyFuncion_Click'>  " + posts[i] + " </a></h3>" +
                                    "  <div class='row'>" +
                                      "  <div class='col-xs-9'> " +
                                      posts[i + 1] +
                                         " </div>" +
                                        "<div class='col-xs-3'></div>" +
                                        
                                      posts[i + 2] +
                                     " </div>" +
                                      "<br><br>" +
                                  "  </div>" +
                                 " </div>" +
    
                   "   <!--/stories-->" +
    
    
                   " </div>" +
                 " </div>" +
    
    
    
               "	</div><!--/col-12-->" +
             " </div>" +
            "</div>";
            lit.Add(someLit);
                 }  
                for(int i=0; i<lit.Count; i++)
                {
                    this.Controls.Add(lit[i]);
                }

    I use one of the list positions as the text for a link in two different spots. For now, lets only talk about the line:

     <a href='#' runat='server'  onserverclick='UserProfile_Click'>" + posts[i + 3] + " </a>

    Since I am generating these controls at pageLoad, I can't make them <asp:Linkbutton>s. And since they are anchor elements, I don't have access to an onCommand attribute or onservercommand attribute.

    All I want to do is access the content from inside the specific link tags that I generate on link click and set it as a session variable. That's what I would like my UserProfile_Click function to do. I cant commandargs it in like i can with a linkbutton's OnCommnad attribute, however.

    My fear is that the onserverclick attribute resolves so something else on pageLoad normally and since I am generating it the way I am similar to the way a <asp:linkButton> resolves to a generated JavaScript.

    Any help?



    • Edited by Brunellus Thursday, April 23, 2015 8:11 PM
    • Moved by Kristin Xie Friday, April 24, 2015 11:36 AM
    Thursday, April 23, 2015 8:04 PM

Answers

  • @Brunellus

    For questions related to ASP.NET use the ASP.NET forum http://forums.asp.net     
    You should get more, better and faster answers on the other forum.  Thanks, ahead of time.

    Best Regards,

    Kristin


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Proposed as answer by Just Karl Friday, April 24, 2015 5:25 PM
    • Marked as answer by Just Karl Monday, May 4, 2015 10:32 PM
    Friday, April 24, 2015 11:36 AM

All replies

  • I do not see the line a code you assign your Literal text to any session variable like

    https://msdn.microsoft.com/en-us/library/ms178581(v=vs.140).aspx

    chanmm


    chanmm

    Friday, April 24, 2015 2:00 AM
  • @Brunellus

    For questions related to ASP.NET use the ASP.NET forum http://forums.asp.net     
    You should get more, better and faster answers on the other forum.  Thanks, ahead of time.

    Best Regards,

    Kristin


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Proposed as answer by Just Karl Friday, April 24, 2015 5:25 PM
    • Marked as answer by Just Karl Monday, May 4, 2015 10:32 PM
    Friday, April 24, 2015 11:36 AM