javascriptasp.netaspbuttonpostbackurl

Sending java script variable value as part of PostBackUrl query string


I need to send a parameter value into a query string of a PostBackUrl method within asp button.

The value I need is already being captured within a java script function shown below.

How do I send the value in hiddId as part of URL ? The below method isn't working. Can someone please help ?

   <script language="javascript" type = "text/javascript">
        function btn_Selected() {
           var hiddId = null;
           $('#<%=GridView1.ClientID %>').find('input[type=radio]:checked').each(function () {
               hiddId = $(this).closest('tr').find('input[type = "hidden"]').val();
           });

     }

 <asp:Button ID="Btn_Update" runat="server" Text="Update" PostBackUrl="Screen_Edit.aspx?CustID='<%=hiddId%>'"

Solution

  • Instead of a post-back, just redirect using JavaScript.

    function btn_Selected() {
               var hiddId = null;
               $('#<%=GridView1.ClientID %>').find('input[type=radio]:checked').each(function () {
                   hiddId = $(this).closest('tr').find('input[type = "hidden"]').val();
               });
               window.location.href = "Screen_Edit.aspx?CustID='" + hiddId + "'"
         }