|
Rank: Member Groups: Member
Joined: 10/31/2007 Posts: 18
|
I'm trying to figure out how to reference controls inside a dialog box from client-side javascript. I'm attempting to change the value in a textbox which resides inside the EO dialog box... I want to clear the textbox if the user clicks the cancel button.
Thanks for any assistance.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi Ray,
You would use:
document.getElementById("<%=TextBox1.ClientID%>').value = "";
Thanks
|
|
Rank: Member Groups: Member
Joined: 10/31/2007 Posts: 18
|
I've tried all of these... none work?
function newOrderCancel() { // Your example... document.getElementById('<%=txtNewOrderOrderno.ClientID%>').value = ""; //'document.getElementById("<%=txtNewOrderOrderno.ClientID%>").value = ""; //NO: eo_GetObject("<%= txtNewOrderOrderno.ClientID %>").value = ""; //document.getElementById("<%=txtNewOrderOrderno.ClientID%>").value = ""; //NO: document.getElementById("txtNewOrderOrderno.ClientID").value='blah blah' //NO: document.getElementById("<%=txtNewOrderOrderno.ClientID%>").value = ""; //NO: document.getElementById("txtNewOrderOrderno").value = ""; //NO: document.getElementById("<%=txtNewOrderOrderno.ClientID%>").value = ""; //NO: document.getElementById("txtNewOrderOrderno.ClientID").value = ""; } ... and all I get is getElementById is null or not an object...
here's the control reference in the aspx file inside of the (<eo:Dialog ID="DialogNewOrder"... ):
<asp:TextBox ID="txtNewOrderOrderno" runat="server" Font-Names="Tahoma" Font-Size="10pt" Style="z-index: 105; left: 172px; position: absolute; top: 27px" TabIndex="1"></asp:TextBox>
This is asp.net.... 2005.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
Do you use ContentTemplate? Try view the page source and get the full ClientID of the textbox, it would be something like "xxxDialogNewOrder_xx_txtNewOrderOrderno", use that value to replace the getElementId argument.
If you do not wish to use hardcoded value, you can replace:
document.getElementById("<%=txtNewOrderOrderno.ClientID%>")
with:
document.getElementById("<%=GetTextBoxClientID()%>")
Here GetTextBoxClientID would be a function you implement:
protected string GetTextBoxClientID() { System.Web.UI.Control textbox = DialogNewOrder.ContentContainer.FindControl("txtNewOrderOrderno"); return textbox.ClientID; }
Note you may need to replace DialogNewOrder.ContentContainer with DialogNewOrder.FooterContainer if the text box is in the dialog's footer template.
Thanks
|
|
Rank: Member Groups: Member
Joined: 10/31/2007 Posts: 18
|
Thanks, the first option worked: DialogNewOrder_ctl00_txtNewOrderOrderno was the source ID... I tried to use the function... but couldn't get it working... for now... I may visit that later...
Question... being that I 'hardcoded' the ID... does it ever change, or is it static?
Thanks again!
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
The ID won't change unless you change its parent's ID. For example, if you change the Id of the dialog, then the ClientID of the textbox will also change.
Thanks
|
|