Reputation: 460
I have a datalist for list of documents
<asp:DataList ID="DLDossierList" runat="server" >
<ItemTemplate>
<div class="doss_hea_seno_2" url="dossier_timeline.aspx">
.
.
<asp:HiddenField ID="hfDocNo" runat="server" Value='<%#("DoCNo") %>' />
.
</div>
</ItemTemplate>
</asp:DataList>
I want to redirect to another page when he clicks on (div) list item i.e document name . for this I am using following script :
<script>
$(document).ready(function () {
$('.doss_hea_seno_2').click(function () {
window.parent.location = $(this).attr("url");
return false;
});
});
</script>
but now I want to pass hidden field value as a query string . how can i achieve this ?
Upvotes: 0
Views: 449
Reputation: 8008
As I remember, WebForms creates ids for elements like Somthing_DLDossierList_hfDocNo
Then you can look for the hidden input field like this:
$('[id$="hfDocNo"]').val() // -> value of the field
Upvotes: 0
Reputation: 2126
You can have the custom query string as data attribute (data-querystring) and do something similar to the following:
You can add the data attribute on DataBound from code behind
<script>
$(document).ready(function () {
$('.doss_hea_seno_2').click(function () {
window.parent.location = $(this).attr("url") + "?customqs=" + $(this).data("querystring");
return false;
});
});
</script>
Upvotes: 1