1

This is my javascript function where value comes from other page and it is received perfectly, but How can i retrieve "divConversation" value in cs page . This is my code

 function myLoad() {

        document.getElementById('divConversation').innerText = getParameterByName("id");


    }
4

2 回答 2

1

The Main Problem With Your Requirement is that the server side code is executed first, So what you need is to receive the passed value on page_load instead of receiving on aspx page.

And this can be done by

String passedValue=Request.QueryString["id"] as string;
于 2013-11-01T06:18:20.477 回答
0

This is a really simple demonstration:

aspx/markup; this will set the value of your hidden field as you type

<form id="form1" runat="server">
<div>
    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>

    <asp:HiddenField ID="HiddenField1" runat="server" />
    <asp:Button ID="Button1" runat="server" Text="Button" />
</div>
</form>
<script>
    document.getElementById('<%= TextBox1.UniqueID %>').onkeyup = function (evt) {
        document.getElementById('<%= HiddenField1.UniqueID %>').value = document.getElementById('<%= TextBox1.UniqueID %>').value;
    }
</script>

Code behind (.cs)

protected void Page_Load(object sender, EventArgs e)
{
    Response.Write(HiddenField1.Value);
}
于 2013-10-20T20:39:02.010 回答