Access code in HTML from Code-Behind

Last post 04-29-2008 1:08 PM by lberan. 2 replies.

Sort Posts:

  • Access code in HTML from Code-Behind

    04-29-2008, 11:22 AM
    • Loading...
    • GregSQL
    • Joined on 07-02-2007, 7:27 PM
    • Posts 58

    I'm trying to access a variable I have in the HTML from my Code-Behind either by adding it as a session variable or making it the text of a textbox.

     Neither is working.

    <%

    Dim ItemNo As String

    ItemNo = Request.QueryString("itemno")

    Response.Write(ItemNo)

    Session.Add(
    "ItemNo", ItemNo)

    %>

     

    <asp:TextBox ID="ItemNo" runat="server" Text='<%# Request.QueryString("itemno") %>'></asp:TextBox>

     The value of ItemNo is output to the screen. However, when I try to access Session.Item("ItemNo") from the code behind, I'm having trouble.

     I've also tried using the text of a textbox approach as seen above. The textbox doesn't show the text.

    What am I doing wrong?

  • Re: Access code in HTML from Code-Behind

    04-29-2008, 1:02 PM
    Answer
    • Loading...
    • GregSQL
    • Joined on 07-02-2007, 7:27 PM
    • Posts 58

    The answer was to simply do this in the code-behind instead of the HTML

     

    Dim ItemNo As String

    ItemNo = Request.QueryString("itemno")

     

    Sorry, I'm a doofus sometimes.

  • Re: Access code in HTML from Code-Behind

    04-29-2008, 1:08 PM
    Answer
    • Loading...
    • lberan
    • Joined on 02-12-2008, 2:23 PM
    • Pittsburgh, PA
    • Posts 452

    in .aspx page:

    <asp:TextBox ID="ItemNo" runat="server" ></asp:TextBox>

     

    in .aspx.vb file:

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    ItemNo.Text = Request.QueryString("itemno")

    Session("itemno") = Request.QueryString("itemno")

    End Sub

    Lynn

    Please remember to click "Mark as Answer" on the post to all the replies that have helped you so that these answers could help others. Thanks.
Page 1 of 1 (3 items)