how to call Request.QueryString inside javascript function and i am using asp.net and C#
var str=<%=Request.quesryString("val")%>
but it is giving me error
If this javascript code is inline in your webform the correct way is to use a javascript serializer:
<script type="text/javascript">
var str = <%= new JavaScriptSerializer().Serialize(Request.QueryString["val"]) %>;
alert(str);
</script>
Never do the following, it's completely unsafe and your site vulnerable to XSS injection attacks:
<script type="text/javascript">
var str = '<%= Request.QueryString["val"] %>';
alert(str);
</script>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With