0

I need to pass the pass value stored in a asp hiddenfield to a querystring using the window.open.

onclick="window.open('../New/FeedbackV4.aspx','FeedbackWindow','width=960,height=640,scrollbars=yes,resizable=yes,status=yes')"

I need to get the value of the hidden field and pass it as a querystring

Joshua
  • 2,275
  • 7
  • 41
  • 57

2 Answers2

0

Assuming for simplicity that the hidden field has an id attribute, say id='foo' (if not, you will need to find another way of picking up that element), use

onclick="window.open('../New/FeedbackV4.aspx?' + par('foo'), ..."

(note the added “?”)

with

<script>
function par(elid) {
  var elem = document.getElementById(elid);
  return encodeURI(elem.name) + '=' + encodeURI(elem.value);
}
</script>
Jukka K. Korpela
  • 195,524
  • 37
  • 270
  • 390
0

I'm not sure I quite understand the context, but given a HiddenField:

<asp:HiddenField ID="hf_myhiddenfield" runat="server" Value="hidden value"/>

You can use a Javascript function to insert the value into your onclick attribute

onclick

onclick="window.open('../New/FeedbackV4.aspx'+GetHFValue(),'FeedbackWindow','width=960,height=640,scrollbars=yes,resizable=yes,status=yes')"   

Javascript

<script type="text/javascript">
    function GetHFValue() {
        var hf_value = '?' + document.getElementById("<%= hf_myhiddenfield.ClientID %>").value;
        return hf_value;
    }
</script>
Brissles
  • 3,833
  • 23
  • 31