admin管理员组文章数量:1023071
I am trying to get CLientID inside the .ascx (user control mark-up) file.
While this
My id is: <%=this.ClientID%>
renders as My id is: fracTemplateCtrl
This:
<asp:Button ID="btnSave" runat="server" Text="Save Template" onclick="btnSave_Click" OnClientClick="return confirmSave('<%=this.ClientID%>');" />
renders as (inside Source code):
<input type="submit" name="fracTemplateCtrl$btnSave" value="Save Template" onclick="return confirmSave('<%=this.ClientID%>');" id="fracTemplateCtrl_btnSave" />
Clearly, ClientId property does not get evaluated in the second case. How do I overe this issue? (aside from hardcoding, which is not the answer, I would like to make the user control independent)
I am trying to get CLientID inside the .ascx (user control mark-up) file.
While this
My id is: <%=this.ClientID%>
renders as My id is: fracTemplateCtrl
This:
<asp:Button ID="btnSave" runat="server" Text="Save Template" onclick="btnSave_Click" OnClientClick="return confirmSave('<%=this.ClientID%>');" />
renders as (inside Source code):
<input type="submit" name="fracTemplateCtrl$btnSave" value="Save Template" onclick="return confirmSave('<%=this.ClientID%>');" id="fracTemplateCtrl_btnSave" />
Clearly, ClientId property does not get evaluated in the second case. How do I overe this issue? (aside from hardcoding, which is not the answer, I would like to make the user control independent)
Share Improve this question edited Apr 19, 2015 at 11:44 niton 9,20923 gold badges35 silver badges56 bronze badges asked Mar 23, 2009 at 22:48 sarsnakesarsnake 27.8k62 gold badges185 silver badges295 bronze badges2 Answers
Reset to default 3You could set the OnClientClick property's value server-side like this:
btnSave.OnClientClick = "return confirmSave('" + this.ClientID + "')";
Try this instead
<asp:Button ID="btnSave" runat="server" Text="Save Template" onclick="btnSave_Click" OnClientClick="return confirmSave(this.id);" />
I am trying to get CLientID inside the .ascx (user control mark-up) file.
While this
My id is: <%=this.ClientID%>
renders as My id is: fracTemplateCtrl
This:
<asp:Button ID="btnSave" runat="server" Text="Save Template" onclick="btnSave_Click" OnClientClick="return confirmSave('<%=this.ClientID%>');" />
renders as (inside Source code):
<input type="submit" name="fracTemplateCtrl$btnSave" value="Save Template" onclick="return confirmSave('<%=this.ClientID%>');" id="fracTemplateCtrl_btnSave" />
Clearly, ClientId property does not get evaluated in the second case. How do I overe this issue? (aside from hardcoding, which is not the answer, I would like to make the user control independent)
I am trying to get CLientID inside the .ascx (user control mark-up) file.
While this
My id is: <%=this.ClientID%>
renders as My id is: fracTemplateCtrl
This:
<asp:Button ID="btnSave" runat="server" Text="Save Template" onclick="btnSave_Click" OnClientClick="return confirmSave('<%=this.ClientID%>');" />
renders as (inside Source code):
<input type="submit" name="fracTemplateCtrl$btnSave" value="Save Template" onclick="return confirmSave('<%=this.ClientID%>');" id="fracTemplateCtrl_btnSave" />
Clearly, ClientId property does not get evaluated in the second case. How do I overe this issue? (aside from hardcoding, which is not the answer, I would like to make the user control independent)
Share Improve this question edited Apr 19, 2015 at 11:44 niton 9,20923 gold badges35 silver badges56 bronze badges asked Mar 23, 2009 at 22:48 sarsnakesarsnake 27.8k62 gold badges185 silver badges295 bronze badges2 Answers
Reset to default 3You could set the OnClientClick property's value server-side like this:
btnSave.OnClientClick = "return confirmSave('" + this.ClientID + "')";
Try this instead
<asp:Button ID="btnSave" runat="server" Text="Save Template" onclick="btnSave_Click" OnClientClick="return confirmSave(this.id);" />
本文标签: javascriptClientID inside of ASCX fileStack Overflow
版权声明:本文标题:javascript - ClientID inside of ASCX file - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745478657a2152439.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论