Click here to Skip to main content
15,891,316 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
i have this code in a html file and i wanna set the value of the textbox to a session when i click the hyperlink. how can i do that? please don't point me to tutorials as they are not understandable by me since i'm a total newbie. i'd be really glad if you just post the code right here. here's my code,

ASP.NET
<div class="sign-in-field">
<input type="text" id="searchBox"  runat="server" value="Search Movie" class="txt-field"  onfocus="if(this.value == 'Search Movie') { this.value = ''; }"  önblur="if(this.value == '') { this.value = 'Search Movie'; }" name="s" />
<a id="searchButton"  runat="server" href="SearchMovie.aspx">Search Button  
</div>


i cant figure out a way to take the value when i click that hyperlink..
Posted
Updated 31-Aug-11 18:09pm
v2
Comments
Sergey Alexandrovich Kryukov 31-Aug-11 23:07pm    
If someone just posts the code as you suggest, you won't understand it. If you're really a total newbie as you say, of course. Don't prevent people helping you.
--SA

1 solution

I suggest you to use LinkButton.
Page1.aspx
XML
<div>
          <input type="text" id="txt1" runat="server" /> 
        <asp:LinkButton ID="LinkButton1" runat="server" onclick="LinkButton1_Click">Search</asp:LinkButton>
    </div>

C#
protected void LinkButton1_Click(object sender, EventArgs e)
   {
     if (!String.IsNullOrEmpty(txt1.Value))
        {
       Session["myvalue"] = txt1.value;
       Response.Redirect("Page2.aspx");
       }


   }



On Page2.aspx
C#
protected void Page_Load(object sender, EventArgs e)
    {
       object mypass;
         mypass = Session["myvalue"];
    }


may help
 
Share this answer
 
Comments
aroshlakshan 1-Sep-11 2:13am    
i cant use the link button because i'm using this on a master page and other pages got forms in it. so i cant use this link button inside a form on master page. i cant use this button outside a form. what should i do man??

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900