如何将文本框值从aspx发送到html页面 [英] how to send a textbox value from aspx to html page

查看:74
本文介绍了如何将文本框值从aspx发送到html页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在asp页面的文本框中输入了金额"500".当我单击asp页面的提交按钮时,应该在html页面中检索相同的值.
我该如何在HTML文本框中绑定"500".

I have entered amount ''500'' in textbox which is in asp page.the same value should be retrieved in the html page when i click submit button of the asp page.
how to do that.how will i get ''500'' binded in the html textbox.

推荐答案

在html控件上不设置runat ="server",然后尝试这个

在.aspx页面上

without making runat="server" on html control, then try this

on .aspx page

<head runat="server">
    <title>Untitled Page</title>
    
    <script type="text/javascript">
    
    function HtmlTextboxValue()
    {
    document.getElementById("textbox_html").value=document.getElementById("<%=textbox_temp.ClientID%>").value; 
    }
    
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <asp:hiddenfield id="textbox_temp" runat="server" />
    <div>
        <br />
        <br />
        <br />
        Asp Textbox :     <asp:textbox id="textbox_asp" runat="server" />
        <br />
        <br />
        <br />
        Html Textbox :    <input type="text" id="textbox_html" />
        <br />
        <br />
        <br />
        <asp:button id="Button1" runat="server" text="Button" onclick="Button1_Click" />
    </div>
    </form>
</body>



在.cs页面后面的代码中



on codebehind .cs page

protected void Button1_Click(object sender, EventArgs e)
    {

        textbox_temp.Value = textbox_asp.Text;
        Page.ClientScript.RegisterStartupScript(Type.GetType("System.String"), "addScript", "HtmlTextboxValue()", true);

    }


为TextBox设置ClientIdMode ="Static"
此操作,serverSide和ClientSide中的文本框的ID相等!
如果您插入代码,那么更好地帮助您
Set ClientIdMode="Static" for TextBox
this Action, Id Of textbox in serverSide And ClientSide Equaled!
if You Insert Your Code Then Better Me to Help you


如果您准备在html控件上制作runat ="server",那么请尝试此

在.aspx页面上
If you are ready to make runat="server" on html control, then try this

on .aspx page
<form id="form1" runat="server">
    <div>
        <br />
        <br />
        <br />
        Asp Textbox :     <asp:textbox id="textbox_asp" runat="server" />
        <br />
        <br />
        <br />
        Html Textbox :    <input type="text" runat="server" id="textbox_html" />
        <br />
        <br />
        <br />
        <asp:button id="Button1" runat="server" text="Button" onclick="Button1_Click" />
    </div>
    </form>



在.cs文件后面的代码中



On codebehind .cs file

protected void Button1_Click(object sender, EventArgs e)
    {
        textbox_html.Value = textbox_asp.Text;

    }


这篇关于如何将文本框值从aspx发送到html页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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