Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Prevent controls from inheirting ID of parent

Reply
Thread Tools

Prevent controls from inheirting ID of parent

 
 
Alex
Guest
Posts: n/a
 
      09-29-2004
I am building a grid which I am adding my own templated columns to. One of
the columns has a checkbox and I am assiging the checkbox an ID based on the
row of the griid. When the grid gets built, the checkbox ID is changed so
that it is a combination of the parent control IDs and its id. Is there any
way to prevent this behaviour?

Thanks,

Alex Gadea
 
Reply With Quote
 
 
 
 
Teemu Keiski
Guest
Posts: n/a
 
      09-29-2004
Hi,

not really unless you play with only client-side controls (e.g have
client.side HTML which doesn't use server controls).

Certainly you could get over it by assigning the ID (per row, whuch you get
from db) to DataGrid's DataKeyField and get it from there when you get
reference to any particular CheckBox in the grid (the current DataGridItem
is Parent's Parent to the CheckBox in control hierarchy amd with
DataGridItem you get the info on which row you are on the grid).

Idea is exactly opposite to your custom naming that you don't acuyally need
to name them yourself, you can use other means. One other way would be using
just HTML checkboxes (<input type="checkbox" runat="server" />) for which
you could according to the HTML model assign also value to the Value
attribute/property. That's another place where you could place the ID
special to the row/checkbox

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
http://blogs.aspadvice.com/joteke


"Alex" <> wrote in message
news:0ACBA69E-5E8E-45D6-AC80-...
> I am building a grid which I am adding my own templated columns to. One

of
> the columns has a checkbox and I am assiging the checkbox an ID based on

the
> row of the griid. When the grid gets built, the checkbox ID is changed so
> that it is a combination of the parent control IDs and its id. Is there

any
> way to prevent this behaviour?
>
> Thanks,
>
> Alex Gadea



 
Reply With Quote
 
 
 
 
Alex
Guest
Posts: n/a
 
      09-29-2004
Actually, the big reason I wanted to override this is that we use Guids for
our IDs and we wind up having a name and id property that approaches 100
characters for each checkbox. And then you add 30 checkboxes to a page,
you've suddenly got 1k worth of Ids for no particular reason.

Alex

"Teemu Keiski" wrote:

> Hi,
>
> not really unless you play with only client-side controls (e.g have
> client.side HTML which doesn't use server controls).
>
> Certainly you could get over it by assigning the ID (per row, whuch you get
> from db) to DataGrid's DataKeyField and get it from there when you get
> reference to any particular CheckBox in the grid (the current DataGridItem
> is Parent's Parent to the CheckBox in control hierarchy amd with
> DataGridItem you get the info on which row you are on the grid).
>
> Idea is exactly opposite to your custom naming that you don't acuyally need
> to name them yourself, you can use other means. One other way would be using
> just HTML checkboxes (<input type="checkbox" runat="server" />) for which
> you could according to the HTML model assign also value to the Value
> attribute/property. That's another place where you could place the ID
> special to the row/checkbox
>
> --
> Teemu Keiski
> MCP, Microsoft MVP (ASP.NET), AspInsiders member
> ASP.NET Forum Moderator, AspAlliance Columnist
> http://blogs.aspadvice.com/joteke
>
>
> "Alex" <> wrote in message
> news:0ACBA69E-5E8E-45D6-AC80-...
> > I am building a grid which I am adding my own templated columns to. One

> of
> > the columns has a checkbox and I am assiging the checkbox an ID based on

> the
> > row of the griid. When the grid gets built, the checkbox ID is changed so
> > that it is a combination of the parent control IDs and its id. Is there

> any
> > way to prevent this behaviour?
> >
> > Thanks,
> >
> > Alex Gadea

>
>
>

 
Reply With Quote
 
Robert Koritnik
Guest
Posts: n/a
 
      09-30-2004
If you don't need GUIDs on the client side, I suggest you to take a
different approach. On the server side you had to rebind the data to get the
checkboxes, so you already have access to GUIDs. But if you need GUIDs, you
could add them to some custom checkbox attribute:

checkbox1.Attributes.Add("rowGUID", yourguid.ToString());

Using this technique, attribute would be ignored by the client HTML parser
and you could easily access guid (without regular expression changes to
string) with Javascript or on the server.

This way you could read the guids on the client and the server side.
Checkbox IDs would stay as they are. Framework does the naming this way to
prevent different controls to share the same ID, which would result in an
error.

--
RobertK
{ Clever? No just smart. }


"Alex" <> wrote in message
news:7C7717DD-CE54-4C83-B6CE-...
> Actually, the big reason I wanted to override this is that we use Guids

for
> our IDs and we wind up having a name and id property that approaches 100
> characters for each checkbox. And then you add 30 checkboxes to a page,
> you've suddenly got 1k worth of Ids for no particular reason.
>
> Alex
>
> "Teemu Keiski" wrote:
>
> > Hi,
> >
> > not really unless you play with only client-side controls (e.g have
> > client.side HTML which doesn't use server controls).
> >
> > Certainly you could get over it by assigning the ID (per row, whuch you

get
> > from db) to DataGrid's DataKeyField and get it from there when you get
> > reference to any particular CheckBox in the grid (the current

DataGridItem
> > is Parent's Parent to the CheckBox in control hierarchy amd with
> > DataGridItem you get the info on which row you are on the grid).
> >
> > Idea is exactly opposite to your custom naming that you don't acuyally

need
> > to name them yourself, you can use other means. One other way would be

using
> > just HTML checkboxes (<input type="checkbox" runat="server" />) for

which
> > you could according to the HTML model assign also value to the Value
> > attribute/property. That's another place where you could place the ID
> > special to the row/checkbox
> >
> > --
> > Teemu Keiski
> > MCP, Microsoft MVP (ASP.NET), AspInsiders member
> > ASP.NET Forum Moderator, AspAlliance Columnist
> > http://blogs.aspadvice.com/joteke
> >
> >
> > "Alex" <> wrote in message
> > news:0ACBA69E-5E8E-45D6-AC80-...
> > > I am building a grid which I am adding my own templated columns to.

One
> > of
> > > the columns has a checkbox and I am assiging the checkbox an ID based

on
> > the
> > > row of the griid. When the grid gets built, the checkbox ID is

changed so
> > > that it is a combination of the parent control IDs and its id. Is

there
> > any
> > > way to prevent this behaviour?
> > >
> > > Thanks,
> > >
> > > Alex Gadea

> >
> >
> >



 
Reply With Quote
 
Alex
Guest
Posts: n/a
 
      09-30-2004
Actually, I just wound up rebuilding the checkbox controls using literals and
doing my own management of the postback. A little more coding, but it
eliminated my main problem which was the huge Ids that were being passed
around.

Thanks for the suggestion.

Alex

"Robert Koritnik" wrote:

> If you don't need GUIDs on the client side, I suggest you to take a
> different approach. On the server side you had to rebind the data to get the
> checkboxes, so you already have access to GUIDs. But if you need GUIDs, you
> could add them to some custom checkbox attribute:
>
> checkbox1.Attributes.Add("rowGUID", yourguid.ToString());
>
> Using this technique, attribute would be ignored by the client HTML parser
> and you could easily access guid (without regular expression changes to
> string) with Javascript or on the server.
>
> This way you could read the guids on the client and the server side.
> Checkbox IDs would stay as they are. Framework does the naming this way to
> prevent different controls to share the same ID, which would result in an
> error.
>
> --
> RobertK
> { Clever? No just smart. }
>
>
> "Alex" <> wrote in message
> news:7C7717DD-CE54-4C83-B6CE-...
> > Actually, the big reason I wanted to override this is that we use Guids

> for
> > our IDs and we wind up having a name and id property that approaches 100
> > characters for each checkbox. And then you add 30 checkboxes to a page,
> > you've suddenly got 1k worth of Ids for no particular reason.
> >
> > Alex
> >
> > "Teemu Keiski" wrote:
> >
> > > Hi,
> > >
> > > not really unless you play with only client-side controls (e.g have
> > > client.side HTML which doesn't use server controls).
> > >
> > > Certainly you could get over it by assigning the ID (per row, whuch you

> get
> > > from db) to DataGrid's DataKeyField and get it from there when you get
> > > reference to any particular CheckBox in the grid (the current

> DataGridItem
> > > is Parent's Parent to the CheckBox in control hierarchy amd with
> > > DataGridItem you get the info on which row you are on the grid).
> > >
> > > Idea is exactly opposite to your custom naming that you don't acuyally

> need
> > > to name them yourself, you can use other means. One other way would be

> using
> > > just HTML checkboxes (<input type="checkbox" runat="server" />) for

> which
> > > you could according to the HTML model assign also value to the Value
> > > attribute/property. That's another place where you could place the ID
> > > special to the row/checkbox
> > >
> > > --
> > > Teemu Keiski
> > > MCP, Microsoft MVP (ASP.NET), AspInsiders member
> > > ASP.NET Forum Moderator, AspAlliance Columnist
> > > http://blogs.aspadvice.com/joteke
> > >
> > >
> > > "Alex" <> wrote in message
> > > news:0ACBA69E-5E8E-45D6-AC80-...
> > > > I am building a grid which I am adding my own templated columns to.

> One
> > > of
> > > > the columns has a checkbox and I am assiging the checkbox an ID based

> on
> > > the
> > > > row of the griid. When the grid gets built, the checkbox ID is

> changed so
> > > > that it is a combination of the parent control IDs and its id. Is

> there
> > > any
> > > > way to prevent this behaviour?
> > > >
> > > > Thanks,
> > > >
> > > > Alex Gadea
> > >
> > >
> > >

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Inheirting constructor? jbo5112 C++ 2 01-05-2011 05:48 AM
If a class Child inherits from Parent, how to implementChild.some_method if Parent.some_method() returns Parent instance ? metal Python 8 10-30-2009 10:31 AM
Prevent a parent object's destructor from being called? Pete C C++ 6 10-30-2005 02:47 PM
Prevent Parent Reload From Window.Open windfall1@gmail.com Javascript 0 10-27-2005 09:03 PM
How to force the child controls OnClick event before the parent controls CreateChildControls method? Arulraja ASP .Net 3 10-17-2003 04:22 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57