|
So I found the sh*t myself
asp.net renders a user control differnt than a normal control. The ID of a user control on the webpage is a combination of the ID used on the page and that in the user control HTML code.
Best way: look at the source code of the page created by asp.net and wich ID asp.net used to address the specific control.
Ex.
If the user control is implemented the following way:
|ucSod:sodat ID="sodatum" runat="server"/>
client script access is thru: formxxx.sodatum_sodat.value
(there's a '<' instead of the '|', but then it's not displayed in the forum, why???
-- modified at 9:36 Monday 26th February, 2007
|
|
|
|
|
wilf57 wrote: So I found the sh*t myself
asp.net renders a user control differnt than a normal control. The ID of a user control on the webpage is a combination of the ID used on the page and that in the user control HTML code.
I told you so. Didn't you read my post before you replied to it?
Best way: look at the source code of the page created by asp.net and wich ID asp.net used to address the specific control.
No, the best way is to use the ClientID property, just as I wrote in my previous post. The way that the id is created may change with the version of framework, but the ClientID property will always return the correct id.
---
single minded; short sighted; long gone;
|
|
|
|
|
the last one is an argument, but still:
if there is a user control on the page like this:
<ucSod:sodat ID="sodatum" runat="server"/>
then
document.getElementById("sodatum").value
doesn't work
what works is:
document.getElementById("sodatum_sodat").value
try it (I'm using ie6)
for me it seems logical, because if the control's ID in the server produced HTML code is 'sodatum_sodat' any javascript cannot access the control by 'sodatum'
|
|
|
|
|
You are completely missing the point.
Use the ClientID property to get the name to use in the client code.
If you hard code the name, your code only works with the exact structure that your page has. If anything changes in that structure, the name changes. Also, you can only use the code for that single page, you can't put the user control in another page if it doesn't have the exact same structure.
Also, if you deply the application to a web server, it's not certain that it will use the same pattern to create the name. An update of IIS or the framework may also change the way that the name is constructed.
---
single minded; short sighted; long gone;
|
|
|
|
|
Ok I got that. I read about it in the help too.
<form id="frmSuchen" runat="server" method="post">
<asp:TextBox ID="artnr" runat="server"></asp:TextBox>
<ucSod:sodat ID="sodatum" runat="server"/>
</form>
Now I tried this in the client script:
document.getElementById("<%=artnr.ClientID%>").value
document.getElementById("<%=sodatum.ClientID%>").value
the first statement with the textbox works fine, the second one with the user control doesn't it says:
document.getElementById("<%=sodatum.ClientID%>")is not an object.
and indeed when I execute on the server side (in page_load() or even aftzer loading in a button event:
Msgbox me.sodatum.ClientID
it always prints 'sodatum' and not 'sodatum_sodat' as I'd have expected.
any explainations?
Thanks for your patience
Wilfried
|
|
|
|
|
Is the client script inside the user control? Otherwise you can not reference the controls in that way, you have to specify that they are in the user control. You also have to change their accessibility to public, or expose them through public properties in the user control.
Are you sure that the first one works correctly? Do you get the value from the field in the user control and not the field in the page?
---
single minded; short sighted; long gone;
|
|
|
|
|
The first one is simply a textbox on the page. Thats why it works fine.
The client script is on the page, not in the user control.
I wrote a public property (Text) in the user control, so I can read and write the listbox(the one in the user control) on the server side but that doesn't help on the page client side, right?!
So you say in the page client script I cannot access the listbox inside the user control by its ClientID property , only by the hard coded ID.
Ok next week I'm going skiing, I have do deal with that thing after that.
Thanks again
Wilfried
|
|
|
|
|
wilf57 wrote: I wrote a public property (Text) in the user control, so I can read and write the listbox(the one in the user control) on the server side but that doesn't help on the page client side, right?!
The property is not for use on the client side, but on the server side.
wilf57 wrote: So you say in the page client script I cannot access the listbox inside the user control by its ClientID property , only by the hard coded ID.
You can never access a control from the client side, regardless of where it is. The control only exists on the server side, the only thing that is left of it on the client side is the html elements that it renders.
The concept of a user control doesn't exist on the client side. You can access any element in the page, regardless of how the code for it is created on the server.
What you have to do is simply get access to the right control so that you can get the ClientID for it, then you can use that in the client code to access the control without problem.
---
single minded; short sighted; long gone;
|
|
|
|
|
Hi All
I want to link the data result set from the database, to a DataGrid. I want to display it other than just columns as it comes from the database.
ie. The usual DataGrid format
------------------------------------------------------
Column Data | Column Data | Column Data | Column Data
------------------------------------------------------
I want to display like this:
-------------------------------
Column Data |
-------------|
Column Data | Column Data
-------------|
Column Data |
-------------------------------
Hope that makes sense.
Thanks in advance.
|
|
|
|
|
You can do that,
use Template Field columns in grid view and arrange the column data as needed.
but you can bind the controls using server tags not by data field property.
like Text='<%#DataBinder.Eval(DataBinder.GetDataItem(Container),"Key")%>'
<asp:GridView runat="server" ID="CustomGridView">
<Columns>
<asp:TemplateField>
place you controls as needed here...
</asp:TemplateField>
</Columns>
</asp:GridView>
Cheers
asithangae
|
|
|
|
|
|
Use repeater web server control.
Regards,
Mark
|
|
|
|
|
i want to have textboxes in a panel dynamically for each selected item in listbox to enter the corresponding value..what sould i do?
|
|
|
|
|
There are basically two ways of showing controls dynamically:
:: Put all the controls that you need on the page, and use the Visible property do decide which controls are rendered to the final page.
:: Create controls in code behind and add to the page.
As you already know all the possible combinations of controls that you need, I suggest the first method.
---
single minded; short sighted; long gone;
|
|
|
|
|
Hi
To create controls in the pannel : set the parent property of the control to the pannell that you have created; eg
TextBox txtNew = new TextBox();
panel1.Contains(txtNew);
txtNew.Parent=panel1;
hope this is helpful
|
|
|
|
|
no,it's not working
parent property is readonly
|
|
|
|
|
Try the below code....
Dim txt as New TextBox
Panel1.Controls.Add(txt)
|
|
|
|
|
hi
i could set pranent property in windows application, failed in asp.net sorry did not check out ealier, right method panel1.controls.add
|
|
|
|
|
hi all,
I am working on a page where i have a grid to show the data from the table.I want this grid to be refreshed every 5 mins as the data in table updates every 5 mins.
how it is possible to refresh the grid..
plz give ur suggestions on this.
Thanks in Advance,
cheers
sangeet
|
|
|
|
|
Write this tag in your aspx page ( Source View ) after title tag --
where conten is time interval in seconds. This will refresh the complete page. If you want to avoid complete post back, try to use AJAX instead.
Hope this helps.
"A good programmer is someone who looks both ways before crossing a one-way street." -- Doug Linder
coolestCoder
|
|
|
|
|
You can also set this from within the code behinde simply by calling:
Response.AddHeader( "refresh", "1800" );
|
|
|
|
|
I think the best thing to do is make a web part containing the grid,
then you can use Ajax to refresh the data.
Hope this helps ,
Shirish.
|
|
|
|
|
hi all,
I want to dispaly/show an aspx page which contains the related information as the tooltip when mouse is over on that particular column in the r.a.d Grid.
For example,if vehicle column is there in the r.a.d grid then if mouse
points over the data on the particular column then the particular vehicle details should be displyed for each row in Grid.Please guide me.
Hoping the reply soon...
Thanks in advance...
|
|
|
|
|
The R.A.D. people have a forum, that's the best place to ask about their control.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi, Professionals!!! help me please.
I have an error : com1\ASPNET LOG ON FAILED !!!
I'm trying to connect to the SQL Server. ASP.NET & (C#)
But error occured when I compile the program.
Please help me
|
|
|
|