Welcome Guest Search | Active Topics | Sign In | Register

reference textboxes and controls in Dialog, through javascript Options
Ray Bradley
Posted: Tuesday, March 18, 2008 5:06:28 PM
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.
eo_support
Posted: Tuesday, March 18, 2008 5:10:13 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi Ray,

You would use:

document.getElementById("<%=TextBox1.ClientID%>').value = "";

Thanks
Ray Bradley
Posted: Tuesday, March 18, 2008 5:33:53 PM
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.
eo_support
Posted: Tuesday, March 18, 2008 6:35:18 PM
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
Ray Bradley
Posted: Tuesday, March 18, 2008 6:51:59 PM
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!
eo_support
Posted: Tuesday, March 18, 2008 7:01:34 PM
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


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.