如何从javaScript传递隐藏字段JobID值
我无法从网址(JobID)传递3017
等ID:
http://www.company.winrecruit.com/JobDetails.aspx?Key=3017
请帮助我...抱歉我的英语不好......
任何想法都非常感激!
<asp:GridView ID="gvJob" CssClass="gvStyle" runat="server" AutoGenerateColumns="false"
PageSize="15" AllowPaging="true" OnPageIndexChanging="gvJob_PageIndexChanging">
<PagerStyle CssClass="alphabet-pagination" />
<Columns>
<asp:TemplateField HeaderText="S#">
<ItemTemplate>
<%# gvJob.Rows.Count + 1 + (gvJob.PageIndex * gvJob.PageSize)%>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="JobTitle" HeaderText="Job Title" />
<asp:BoundField DataField="PostedDate" HeaderText="Posted Date" DataFormatString="{0:dd/MM/yyyy}" />
<asp:BoundField DataField="StartDate" HeaderText="Start Date" DataFormatString="{0:dd/MM/yyyy}" />
<asp:BoundField DataField="EndDate" HeaderText="End Date" DataFormatString="{0:dd/MM/yyyy}" />
<asp:BoundField DataField="CreatedBy" HeaderText="Created By" />
<asp:TemplateField HeaderText="Status">
<ItemTemplate>
<asp:LinkButton ID="lbtnStatus" runat="server" CssClass="link" OnClick="lbtnStatus_Click"
ToolTip="To Change Status" CommandArgument='<%# Eval("JobID") %>'>
<img src='images/icons/<%# Eval("Status").ToString() == "Y" ? "ic-status" : "inactive" %>.png' alt="Status" title="<%# Eval("Status").ToString()== "Y" ? "OPEN" : "CLOSED"%>" />
</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Is Active?">
<ItemTemplate>
<asp:LinkButton ID="lbtnActive" runat="server" CssClass="link" OnClick="lbtnActive_Click"
ToolTip="To Change Active Status" CommandArgument='<%# Eval("JobID") %>'>
<img src='images/icons/<%# Eval("IsActive").ToString() == "Y" ? "ic-status" : "inactive" %>.png' alt="Status" title="<%# Eval("IsActive").ToString()== "Y" ? "ACTIVE" : "INACTIVE"%>" />
</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Actions" HeaderStyle-Width="100">
<ItemTemplate>
<a href='Postjob.aspx?Key=<%#Eval("JobID")%>' class="table-actions-button ic-table-edit"
title="Edit"></a>
<asp:ImageButton ID="imgbtnDelete" ImageUrl="~/cpanel/images/icons/table/actions-delete.png"
runat="server" CommandArgument='<%#Eval("JobID")%>' OnClick="imgbtnDelete_Click"
ToolTip="Delete" />
<%--<a href="http://tellafriend.socialtwist.com:80" class="table-actions-button ic-table-share" title="Share" onclick="return false;" style="vertical-align: baseline;"
><span class="share" style="border:none;" onmouseout="STTAFFUNC.hideHoverMap(this)" onmouseover="STTAFFUNC.showHoverMap(this, '2010021335271-2', '<%=ConfigurationManager.AppSettings["SiteUrl"].ToString()%>/jobdetail.aspx?Key=<%#Eval("JobID")%>', '<%# Eval("JobTitle") %> - <%# Eval("SkillSet") %>')"
onclick="STTAFFUNC.cw(this, {id:'2010021335271-2', link:'<%=ConfigurationManager.AppSettings["SiteUrl"].ToString()%>/jobdetail.aspx?Key=<%#Eval("JobID")%>', title: '<%# Eval("JobTitle") %> - <%# Eval("SkillSet") %>' });">
</span></a>--%>
<%-- <a href="http://tellafriend.socialtwist.com:80" title="Share" onclick="return false;" style="vertical-align: baseline;"
><span class="share" style="border:none;" onmouseout="STTAFFUNC.hideHoverMap(this)" onmouseover="STTAFFUNC.showHoverMap(this, '2010021335271-2', '<%=ConfigurationManager.AppSettings["SiteUrl"].ToString()%>/jobdetail.aspx?Key=<%#Eval("JobID")%>', '<%# Eval("JobTitle") %> - <%# Eval("SkillSet") %>')"
onclick="STTAFFUNC.cw(this, {id:'2010021335271-2', link:'<%=ConfigurationManager.AppSettings["SiteUrl"].ToString()%>/jobdetail.aspx?Key=<%#Eval("JobID")%>', title: '<%# Eval("JobTitle") %> - <%# Eval("SkillSet") %>' });">
share</span></a>--%>
<asp:HiddenField ID="hdnJobID" runat="server" Value='<%#Eval("JobID")%>' />
<a href="<%=ConfigurationManager.AppSettings["SiteUrl"].ToString()%>/jobdetail.aspx?Key=<%#Eval("JobID")%>', title: '<%# Eval("JobTitle") %> - <%# Eval("SkillSet") %>" onclick="reply_click(this.id); return false;" class="socialShare" ></a>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
Java脚本
我如何获得Id
价值
<script>
$(function () {
var id = document.getElementById('<%= hdnJobID.ClientID %>');
var url = '<%=ConfigurationManager.AppSettings["SiteUrl"].ToString()%>/jobdetail.aspx?Key=' + id + '';
var options = {
twitter: {
text: 'Check out this awesome jQuery Social Buttons Plugin! ',
via: 'Tutorialzine'
},
facebook: true,
googlePlus: true
};
$('.socialShare').shareButtons(url, options);
});
</script>
由于
答案 0 :(得分:1)
尝试替换
var id = document.getElementById('<%= hdnJobID.ClientID %>');
与
var id = $("#hdnJobId").val();
希望这有助于:)
我假设你的代码中有jquery引用