J
John Kotuby
Hi all,
I'm having a bit of a problem getting the ClientId of some controls to
render as expected in the resulting HTML.
From within the onclick event of an input control of type button, the
imbedded VB code snippets using ClientId render properly as shown below:
Page Source code from input type="button":
onclick="SubmitSearch('<%= btnSearch.ClientID %>','<%=lstMay.ClientId
%>','<%=lstMust.ClientId %>','<%=lstExc.ClientId %>')"
Rendered HTML:
onclick="SubmitSearch('ctl00_Content1_SearchTool1_btnSearch','ctl00_Content1_SearchTool1_lstMay','ctl00_Content1_SearchTool1_lstMust','ctl00_Content1_SearchTool1_lstExc')"
But when I try the same technique from within the OnClientClick event of an
asp:Button, the VB code snippets are rendered literally as below.
Page Source Code from asp:Button:
OnClientClick="return SaveSearch('Y','<%=lstMay.ClientId
%>','<%=lstMust.ClientId %>','<%=lstExc.ClientId %>')"
Rendered HTML:
<input type="submit" name="ctl00$Content1$SearchTool1$btnSaveSearch"
value="Save Search " onclick="return SaveSearch('N','<%=lstMay.ClientId
%>','<%=lstMust.ClientId %>','<%=lstExc.ClientId %>')
I use the syntax "return SaveSearch(...)" for the asp Button in case
client-side validation within the JavaScript function fails and I don't want
the page to post.
Note that these Buttons are contained within a User Control placed on the
page, but I don't think that should make any difference as the input button
code from the same User Control renders properly.
I must be missing a basic concept of .NET 101 here but I'm not sure what it
is.
Thanks for any help with this.
I'm having a bit of a problem getting the ClientId of some controls to
render as expected in the resulting HTML.
From within the onclick event of an input control of type button, the
imbedded VB code snippets using ClientId render properly as shown below:
Page Source code from input type="button":
onclick="SubmitSearch('<%= btnSearch.ClientID %>','<%=lstMay.ClientId
%>','<%=lstMust.ClientId %>','<%=lstExc.ClientId %>')"
Rendered HTML:
onclick="SubmitSearch('ctl00_Content1_SearchTool1_btnSearch','ctl00_Content1_SearchTool1_lstMay','ctl00_Content1_SearchTool1_lstMust','ctl00_Content1_SearchTool1_lstExc')"
But when I try the same technique from within the OnClientClick event of an
asp:Button, the VB code snippets are rendered literally as below.
Page Source Code from asp:Button:
OnClientClick="return SaveSearch('Y','<%=lstMay.ClientId
%>','<%=lstMust.ClientId %>','<%=lstExc.ClientId %>')"
Rendered HTML:
<input type="submit" name="ctl00$Content1$SearchTool1$btnSaveSearch"
value="Save Search " onclick="return SaveSearch('N','<%=lstMay.ClientId
%>','<%=lstMust.ClientId %>','<%=lstExc.ClientId %>')
I use the syntax "return SaveSearch(...)" for the asp Button in case
client-side validation within the JavaScript function fails and I don't want
the page to post.
Note that these Buttons are contained within a User Control placed on the
page, but I don't think that should make any difference as the input button
code from the same User Control renders properly.
I must be missing a basic concept of .NET 101 here but I'm not sure what it
is.
Thanks for any help with this.