[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.aspnet.buildingcontrols

UserControl... where is the clientID on the client side?

Monty

6/21/2007 8:01:00 PM

[ASP.Net 2.0, WAP, Atlas]

I have a custom usercontrol that looks something like this:

<%@ Control Language="vb" AutoEventWireup="false"
Codebehind="ItemPicker.ascx.vb" Inherits="myNS.ItemPicker" %>
<div runat=server id=divMain style="text-align:justify; overflow-x:hidden;">
<div id="divItemList" class="ItemPickerList" runat="server">
<asp:Repeater ID="rprItems" runat="server">
<ItemTemplate>
<div class=ItemPickerItem id='<%#me.uniqueID
%>_<%#Container.DataItem("ItemID")%>'><%#Container.DataItem("Description")%></div>
</ItemTemplate>
</asp:Repeater>
</div>
</div>

In the Page_Load of this control, Me.ClientID =
"ctl00_ContentPlaceHolder1_ItemPicker1". However, when I look at the page
that is rendered, there is no element that has
"ctl00_ContentPlaceHolder1_ItemPicker1" as an ID. There is, of course,
"ctl00_ContentPlaceHolder1_ItemPicker1_divMain". I kinda thought if a
control had a client ID it would, uhhh, have that ID on the client. I tried
wrapping it all in a DIV and setting the DIV ID like so: <div
id='<%=me.clientID%>', but that was a no-go of course. The only reason I
care is because in the page that hosts this control I am registering the
control for AsyncPostBack (like
ScriptManager.RegisterAsyncPostBackControl(ItemPicker1)). In the
__doPostBack event, it is looking for a control with the ID of
"ctl00_ContentPlaceHolder1_ItemPicker1", but of course can't find it. Any
suggestions? TIA!

(Bonus question: is there a MS newsgroup for Atlas?)






2 Answers

wawang

6/22/2007 9:41:00 AM

0

Hi Monty,

I don't think you can use RegisterAsyncPostBackControl on a UserControl
instance. A control has ClientID property, doesn't necessary mean the id
will always be used on the rendered page. For a UserControl, by default it
only acts as a naming container (implements INamingContainer interface).
Child controls inside a naming container will use parent's ClientID as
prefix.

When a control is registered via RegisterAsyncPostBackControl, it must
occur in the posted form data. Usually a control that will post the form
can be used with it.

I also noticed you're using me.UniqueID to generate the client id of the
div; I think you should use ClientID (the difference between UniqueID and
ClientID is the separator used to compose the result from ID property).


There's no dedicated newsgroup for ASP.NET AJAX now, you can just post in
asp.net related newsgroups.


Regards,
Walter Wang (wawang@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Seon

12/16/2010 7:42:00 AM

0



"Government Shill #2" <gov.shill@gmail.com> wrote in message
news:2oejg6d3mjtrmqt8b6r0t60944tu1fin1k@4ax.com...
> On Thu, 16 Dec 2010 07:37:21 +1100, "Seon" <seon@iinet.net.au> wrote:
>
>>
>>
>>"Government Shill #2" <gov.shill@gmail.com> wrote in message
>>news:al7ig6db4vcev3apjdvtrf6vkqf6pgi4sj@4ax.com...
>>> On Thu, 16 Dec 2010 06:32:25 +1100, "Seon" <seon@iinet.net.au> wrote:
>>>
>>>>
>>>>
>>>>"Government Shill #2" <gov.shill@gmail.com> wrote in message
>>>>news:of8hg6l5aam9ha2shjkc36akv3n8nsg3o3@4ax.com...
>>>
>>>>> Then how did Sweden interfere with UK sovereignty?
>>>>>
>>>>Sweeden appealed Julian Assange's bail.
>>>
>>>
>>> So, Sweeden followed the UK's sovereign laws and appealed? How is that
>>> interfering? It is making a request through the proper channels.
>>>
>>Key word: Proper channels.
>
>
> Yes... and?
>
> Proper channels is not interfering. It is the opposite of interfering.
>
>
>>>>> At least the same as it is for stealing anything else.
>>>>>
>>>>> According to this web site:
>>>>> http://www.armstronglegal.com.au/web/page/Receiving_St...
>>>>>
>>>>> "The Maximum penalty for the offence of Receiving stolen property
>>>>> where
>>>>> stealing
>>>>> is a serious offence is 10 years imprisonment."
>>>>>
>>>>>
>>>>.com.au...
>>>
>>> .com.au what?
>>>
>>It's an Aussie site.
>
> Yes. I know. We are in Australia. I gave you an Australian example. On
> purpose.
> What would you like? Can you not find it for yourself? Google intolerant?
>
>
>
>>>>And besides, he received stolen documents. Isn't there a
>>>>difference?
>>>
>>>
>>> No. Why would you think that?
>>>
>>> Try taking a packet of work related documents home tonight and put them
>>> up
>>> on
>>> your Facebook page. You'd be in jail before you managed to shut down
>>> your
>>> PC.
>>>
>>>
>>Yeah he obtained them illegally, just like the climate gate hackers. But
>>you
>>don't see "celebrities" calling them heros do you?
>
>
> Uh????
>
>
>>>>Plus he isn't really publishing anything controversial, just
>>>>what the US really thinks of other countries. Although he did prove that
>>>>the
>>>>US bribed other countries during Copenhagen.
>>>
>>>
>>> He published state secrets. Have you not had the "Need to Know" brief
>>> where you
>>> work? I'm sure you will work with classified documents. I hope you
>>> aren't
>>> really
>>> silly enough to think that you can do what you like with them.
>>>
>>>
>>Of course, if I leaked our confidential documents I'd probably be in jail.
>>So I guess the people who leaked those documents do deserve to go to jail
>>but the trouble is we don't know who they are.
>
>
> No, but we know who received them.
>
>
>>>>> There has never been 100% evidence that there are electrons in
>>>>> electric
>>>>> wires either; however, I don't recommend that you stick a fork in a
>>>>> power
>>>>> outlet.
>>>>>
>>>>But it has been proven,
>>>
>>> 100%? Are you sure about that?
>>>
>>Well most people who stick forks in a power outlet get shocked so you can
>>assume if I did it I would be shocked as well. Shocking.
>
>
> You missed the point. Yes you would get shocked. Would you be 100% sure
> that
> what caused the effect you would feel would be electrons? Have you seen
> 100%
> evidence for this?
>
I know from the fact that people have been shocked by doing this.

>
>>>> it has not been proven however that CO2 can lead to
>>>>global warming.
>>>
>>>
>>> Lots of scientific theories have never been 100% proven. Most can never
>>> be.
>>> Scientists are happy to go with the most probable, until better evidence
>>> comes
>>> along and revises the theory. Science is about enquiry, theorising,
>>> experimentation, comparison of theory to the observable universe, and
>>> adjustment/abandonment of theories that no longer match up.
>>>
>>Exactly not denouncing skeptics as heretics or censoring them from
>>scientific papers. The most probable cause is CO2 causes global warming
>>but
>>they are other theories which seem possible.
>>
>>>
>>>>They are alternative theories which the majority of
>>>>scientists refuse to look at. I thought science was meant to be
>>>>naturally
>>>>skeptical and not a religion.
>>>
>>>
>>> Yes. It is. If the non-majority of scientists, who *are* looking into
>>> the
>>> alternatives, come up with evidence to the contrary, the majority will
>>> be
>>> forced
>>> to come into line. This has happened many times.
>>>
>>What do you think of sunspots
>>http://www.canada.com/nationalpost/financialpost/comment/story.html?id=597d0677-2a05-47b4-b34f-b84068db11...
>>and http://en.wikipedia.org/wiki/File:Temp-sunsp...
>>
>>I will have to read the first link after work.
>
>
> Sunspots can cause warming. So can lots of things. An increase in
> greenhouse
> gasses, for example.
>
> Who says there is only *one* cause?
>
Al Gore, but you could be right. There could be more than one cause, perhaps
humans are contributing to it, perhaps not.

>
>>>>> The consumer, of course. We went over this last week.
>>>>>
>>>>And your ok with paying more for your electricity?
>>>
>>>
>>> No. I never said it was a good or desirable to tax carbon. My mission
>>> has
>>> been
>>> to open your eyes. Look up "Devil's Advocate".
>>>
>>>
>>Ah.
>>Well I have been more open to the possibility I could be wrong now and
>>look
>>at both sides of the argument.
>>
>>>
>>>>> Where else is the government supposed to get the money? For anything?
>>>>>
>>>>The people of course but this will bankrupt America more because the
>>>>people
>>>>are already paying too much tax.
>>>
>>>
>>> I think your understanding of economics might be a bit... naive. Ask one
>>> of your
>>> uni mates who did economics if your theory stacks up.
>>>
>>They still pay too much tax already.
>
>
> Ok. How will this "bankrupt America"?
>
How are American's going to afford it?

> Shill #2
> --
> I am not young enough to know everything.
> Oscar Wilde (1854 - 1900)