将用户输入的URL以aspx格式附加到操作标记

时间:2017-09-29 19:07:38

标签: javascript c# html asp.net

我在clientURLTxtBox中有一个值,它是一些地址,例如:http://localhost/ClientServer/ClientPages/ClientHomePage.aspx

我有一个表格想要将某些值发布到上述网址。

如何将用户inputed clientURLTxtBox附加到表单中的操作标记? 基本上,我想实现这个目标......

<form id="form1" runat="server" method="post" action= ##clientURLTxtBox.Text##>

我提供了额外参考的代码:

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server" method="post" action="<%clientURITxtBox.Text  %>">




<div>

    Hi.. This is the Server Start Page

</div>

    <p>
        <asp:TextBox ID="clientIDTxtBox" runat="server" Visible="False" Rows="1" style="position: absolute; z-index: 1; left: 237px; top: 53px; right: 1055px" TextMode="MultiLine"></asp:TextBox>
        <asp:TextBox ID="clientIDHeader" runat="server" OnTextChanged="clientURITxtBox0_TextChanged" style="position: relative; top: 1px; left: -1px; width: 195px" Visible="False">ClientID:</asp:TextBox>
    </p>

    <p>
        <asp:TextBox ID="clientSecretHeader" runat="server" OnTextChanged="clientURITxtBox0_TextChanged" style="position: relative; top: -16px; left: -4px; width: 195px" Visible="False">Client Secret:</asp:TextBox>
        <asp:TextBox ID="clientSecretTxtBox" runat="server" style="position: relative; top: -4px; left: 21px; width: 203px;" Visible="False" TextMode="MultiLine"></asp:TextBox>
        <asp:TextBox ID="clientURIHeader" runat="server" OnTextChanged="clientURITxtBox0_TextChanged" style="position: relative; top: 42px; left: -416px; width: 195px" Visible="False">Client URI:</asp:TextBox>
    </p>

    <p>
        <asp:TextBox ID="clientURITxtBox" runat="server" style="position: relative; top: -2px; left: 222px; width: 204px"></asp:TextBox>
    </p>
    <p>
        &nbsp;</p>
        <asp:Button ID="SendClientButton" type="submit" runat="server" style="position: relative; top: -1px; left: 61px; width: 145px" Text="SendToClient" Visible="False" />
    </form>

1 个答案:

答案 0 :(得分:0)

找到答案,似乎工作正常。

<script>
    function myFunc() {
        var action_src =  document.getElementById("clientURITxtBox").value;
        var form1 = document.getElementById('form1');
        form1.action = action_src;
        return action_src;
    }
</script>
<body>
<form id="form1" runat="server" method="post" action="http://localhost/OAuthBasic/ROWebPage/RegisterClient.aspx" onsubmit="myFunc()">

在服务器端:通过以下方式接收帖子值:

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!string.IsNullOrEmpty(Request.Form["TextBox1"]))
        {
            // whatever operation you want to perform
        }

    }