如何将此HTML文本框的值转换为aspx.cs文件? [英] how to take the value of this html textbox to aspx.cs file?

查看:113
本文介绍了如何将此HTML文本框的值转换为aspx.cs文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将此代码保存在html文件中,当我单击超链接时,我想将文本框的值设置为会话.我怎样才能做到这一点?请不要将我指向教程,因为我是新手,所以我无法理解它们.如果您将代码发布在这里,我将感到非常高兴.这是我的代码,

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,

<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..

推荐答案

我建​​议您使用LinkBut​​ton.
Page1.aspx
I suggest you to use LinkButton.
Page1.aspx
<div>
          <input type="text" id="txt1" runat="server" /> 
        <asp:LinkButton ID="LinkButton1" runat="server" onclick="LinkButton1_Click">Search</asp:LinkButton>
    </div>


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


   }




在Page2.aspx




On Page2.aspx

protected void Page_Load(object sender, EventArgs e)
    {
       object mypass;
         mypass = Session["myvalue"];
    }



可能会帮助



may help


这篇关于如何将此HTML文本框的值转换为aspx.cs文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆