Author Topic: Updating URL of ASP.NET hyperlink at runtime using jquery  (Read 8848 times)

abhimanyu

  • Newbie
  • *
  • Posts: 10
    • View Profile
Updating URL of ASP.NET hyperlink at runtime using jquery
« on: October 19, 2012, 07:44:04 PM »
Just Add one .js File in header Tag in .aspx page(jquery-1.4.1.min.js)
Code: [Select]
<script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
Than Write one script
Code: [Select]
<script type="text/javascript">
        $(document).ready(function () {
            $("input[type=radio]").bind("change", function () {
                $("a").attr("href", $(this).val());
            });
        });
    </script>

Add an ASP.NET hyperlink control on the page. Also add a RadioButtonList to the form as follows:

Code: [Select]
<form id="form1" runat="server">
    <div align="left">
        <fieldset style="width: 300px; height: 200px;">
            <table cellpadding="0" cellspacing="0" border="0">
                <tr>
                    <td width="10px">
                    </td>
                    <td>
                        <p>
                            Get your news updates here:</p>
                        <asp:RadioButtonList ID="RadioButtonList1" runat="server">
                            <asp:ListItem Text="Learn Extreme-Advice" Value="http://learn.extreme-advice.com"></asp:ListItem>
                            <asp:ListItem Text="Ritesh Blog" Value="http://blog.extreme-advice.com/"></asp:ListItem>
                        </asp:RadioButtonList>
                        <br />
                        <asp:HyperLink ID="HyperLink1" runat="server">Click here!</asp:HyperLink>
                    </td>
                </tr>
            </table>
        </fieldset>
    </div>
    </form>

 :) Happy Coding

Thanks
Abhimanyu Rawat
Regards,
Abhimanyu Rawat