Click to See Complete Forum and Search --> : Access a textbox in a loaded control


kyuss
03-04-2003, 04:09 AM
Hello all,
I'm using some ascx controls I made, which i load within an aspx page (loader.aspx).
The problem I have is that I don't know how to apply most of the JavaScript code I find, because the controls have no <form> tag, so I cannot use the onload event of the form, for example.

the scheme:

loader:
<body>
<form>...

ascx control:
<div>
<asp:textbox>
....

One of the things that I want to do and I can't figure out: I want to set the focus on the textbox just when loading the page, which is pretty easy if working with a normal page. In this case, I don't know how to do it... div onload event?


Thanks in advance :)
kyuss.

kyuss
03-04-2003, 07:41 AM
Hello Dave,
thanks for your rapid reply :)

Yes, I amb using asp.NET.
The problem is that I don't have a <body> nor <form> tag in my control.

There is the loader file which I use to load all my views - ascx web user control files. The loader has only a placeholder:
<body>
<form id="Form1" method="post" runat="server">
<asp:PlaceHolder id="phdr" runat="server">
</asp:PlaceHolder>
</form>
</body>

the ascx control (my view), the file that i load into the placeholder:
<%@ Control Language="c#" AutoEventWireup="false" Codebehind="view1.ascx.cs" ... %>
<asp: panel id="pnl1" ... runat="server">
<DIV ... ms_positioning="GridLayout">
<asp:TextBox id="txtName" ... runat="server" ></asp:TextBox>
... some other controls here
</DIV>
</asp: panel>
...some other panels which I turn visible or invisible depending on the user input progress.

so the form and body tags are in the aspx file and i can't reffer to some control of the ascx file that i load there because the ascx loader file is multi-use; i load a lot more ascx files (views) with other textboxes and controls... i hope you understand what i mean =)

So, how can i put JavaScript code in the ascx file to affect when the panel or div is first loaded and set the focus on a textbox inside one of the divs or panels of the ascx file?

I hope this explanation doesn't cause any headaches ,' )

thanks again,
kyuss.

kyuss
03-05-2003, 10:50 AM
Thanks Dave.
I'm not sure if the solution is with ASP.NET or with JS.
All I know is that i have to access a specific textbox with JS but i can't use <form> or <body> events. Maybe I could try with the <div> events (no luck yet).
Anyway, I'll post this issue on the .NET forum.
Cheers,
kyuss.