javascript string manipulation

javascript string manipulation

am 09.04.2008 17:02:00 von rodchar

hey all,
what's the best way to extract info from the following string:

controlvalueid_ctl02_DrpX

i need "_Drp" and everything to the right of it.

thanks,
rodchar

Re: javascript string manipulation

am 09.04.2008 17:14:57 von mark

"rodchar" wrote in message
news:FBF2B345-6C45-4646-A394-2551D929998A@microsoft.com...

> what's the best way to extract info from the following string:
>
> controlvalueid_ctl02_DrpX
>
> i need "_Drp" and everything to the right of it.

Are you trying to find the server-side control ID, as opposed to the
"munged" client-side control ID...?


--
Mark Rae
ASP.NET MVP
http://www.markrae.net

RE: javascript string manipulation

am 09.04.2008 20:58:02 von brucebarker

var s = 'controlvalueid_ctl02_DrpX'.match(/_Drp.*$/)

-- bruce (sqlwork.com)


"rodchar" wrote:

> hey all,
> what's the best way to extract info from the following string:
>
> controlvalueid_ctl02_DrpX
>
> i need "_Drp" and everything to the right of it.
>
> thanks,
> rodchar

Re: javascript string manipulation

am 09.04.2008 21:01:02 von rodchar

yes Mark but this is the only way i know to get it thru javascript. is there
another way?

"Mark Rae [MVP]" wrote:

> "rodchar" wrote in message
> news:FBF2B345-6C45-4646-A394-2551D929998A@microsoft.com...
>
> > what's the best way to extract info from the following string:
> >
> > controlvalueid_ctl02_DrpX
> >
> > i need "_Drp" and everything to the right of it.
>
> Are you trying to find the server-side control ID, as opposed to the
> "munged" client-side control ID...?
>
>
> --
> Mark Rae
> ASP.NET MVP
> http://www.markrae.net
>
>

Re: javascript string manipulation

am 09.04.2008 21:45:37 von George Ter-Saakov

use
DrpX.ClientID
or sometimes
DrpX.UniqueID

depending on what you need name or id of the control...


George.


"rodchar" wrote in message
news:B0DCBA34-1F4D-4BD1-BA5E-4B82400ADA02@microsoft.com...
> yes Mark but this is the only way i know to get it thru javascript. is
> there
> another way?
>
> "Mark Rae [MVP]" wrote:
>
>> "rodchar" wrote in message
>> news:FBF2B345-6C45-4646-A394-2551D929998A@microsoft.com...
>>
>> > what's the best way to extract info from the following string:
>> >
>> > controlvalueid_ctl02_DrpX
>> >
>> > i need "_Drp" and everything to the right of it.
>>
>> Are you trying to find the server-side control ID, as opposed to the
>> "munged" client-side control ID...?
>>
>>
>> --
>> Mark Rae
>> ASP.NET MVP
>> http://www.markrae.net
>>
>>

Re: javascript string manipulation

am 09.04.2008 22:06:02 von rodchar

but that's on the server-side right? because i'm trying to get to the element
in javascript.

"George Ter-Saakov" wrote:

> use
> DrpX.ClientID
> or sometimes
> DrpX.UniqueID
>
> depending on what you need name or id of the control...
>
>
> George.
>
>
> "rodchar" wrote in message
> news:B0DCBA34-1F4D-4BD1-BA5E-4B82400ADA02@microsoft.com...
> > yes Mark but this is the only way i know to get it thru javascript. is
> > there
> > another way?
> >
> > "Mark Rae [MVP]" wrote:
> >
> >> "rodchar" wrote in message
> >> news:FBF2B345-6C45-4646-A394-2551D929998A@microsoft.com...
> >>
> >> > what's the best way to extract info from the following string:
> >> >
> >> > controlvalueid_ctl02_DrpX
> >> >
> >> > i need "_Drp" and everything to the right of it.
> >>
> >> Are you trying to find the server-side control ID, as opposed to the
> >> "munged" client-side control ID...?
> >>
> >>
> >> --
> >> Mark Rae
> >> ASP.NET MVP
> >> http://www.markrae.net
> >>
> >>
>
>
>

Re: javascript string manipulation

am 09.04.2008 23:08:34 von mark

"rodchar" wrote in message
news:B0DCBA34-1F4D-4BD1-BA5E-4B82400ADA02@microsoft.com...

[top-posting corrected]

>> > what's the best way to extract info from the following string:
>> >
>> > controlvalueid_ctl02_DrpX
>> >
>> > i need "_Drp" and everything to the right of it.
>>
>> Are you trying to find the server-side control ID, as opposed to the
>> "munged" client-side control ID...?
>
> yes Mark but this is the only way i know to get it thru javascript. is
> there
> another way?

You don't need it...

If you have a server-side control called DrpX and want to refer to it in
client-side JavaScript, all you need is:




--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Re: javascript string manipulation

am 10.04.2008 02:03:01 von rodchar

can you use this if the textbox resides in a WebUserControl which in turn is
on the .aspx page?

i tried document.getElementById('<% WebUserControl1_TextBox1 %'>)
but it won't compile, it says TextBox1 doesn't exist in this context.

"Mark Rae [MVP]" wrote:

> "rodchar" wrote in message
> news:B0DCBA34-1F4D-4BD1-BA5E-4B82400ADA02@microsoft.com...
>
> [top-posting corrected]
>
> >> > what's the best way to extract info from the following string:
> >> >
> >> > controlvalueid_ctl02_DrpX
> >> >
> >> > i need "_Drp" and everything to the right of it.
> >>
> >> Are you trying to find the server-side control ID, as opposed to the
> >> "munged" client-side control ID...?
> >
> > yes Mark but this is the only way i know to get it thru javascript. is
> > there
> > another way?
>
> You don't need it...
>
> If you have a server-side control called DrpX and want to refer to it in
> client-side JavaScript, all you need is:
>
>
>
>
> --
> Mark Rae
> ASP.NET MVP
> http://www.markrae.net
>
>

RE: javascript string manipulation

am 10.04.2008 02:42:00 von rodchar

thanks for this one,
rod.

"bruce barker" wrote:

>
> var s = 'controlvalueid_ctl02_DrpX'.match(/_Drp.*$/)
>
> -- bruce (sqlwork.com)
>
>
> "rodchar" wrote:
>
> > hey all,
> > what's the best way to extract info from the following string:
> >
> > controlvalueid_ctl02_DrpX
> >
> > i need "_Drp" and everything to the right of it.
> >
> > thanks,
> > rodchar

Re: javascript string manipulation

am 10.04.2008 11:01:23 von mark

"rodchar" wrote in message
news:E00E874A-1DCE-48BE-AA15-F26A30628B4E@microsoft.com...

[top-posting corrected again]

>> >> > what's the best way to extract info from the following string:
>> >> >
>> >> > controlvalueid_ctl02_DrpX
>> >> >
>> >> > i need "_Drp" and everything to the right of it.
>> >>
>> >> Are you trying to find the server-side control ID, as opposed to the
>> >> "munged" client-side control ID...?
>> >
>> > yes Mark but this is the only way i know to get it thru javascript. is
>> > there
>> > another way?
>>
>> You don't need it...
>>
>> If you have a server-side control called DrpX and want to refer to it in
>> client-side JavaScript, all you need is:
>>
>>
>
> can you use this if the textbox resides in a WebUserControl which in turn
> is
> on the .aspx page?

Yes.

> i tried document.getElementById('<% WebUserControl1_TextBox1 %'>)
> but it won't compile, it says TextBox1 doesn't exist in this context.

Firstly, you need the = sign, which is ASP.NET shorthand for Response.Write

Secondly, you need to specify the .ClientID property of the control whose
munged name you want to return...


--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Re: javascript string manipulation

am 10.04.2008 15:44:04 von rodchar

thanks Mark and everyone for this very helpful thread,
rod.

"Mark Rae [MVP]" wrote:

> "rodchar" wrote in message
> news:E00E874A-1DCE-48BE-AA15-F26A30628B4E@microsoft.com...
>
> [top-posting corrected again]
>
> >> >> > what's the best way to extract info from the following string:
> >> >> >
> >> >> > controlvalueid_ctl02_DrpX
> >> >> >
> >> >> > i need "_Drp" and everything to the right of it.
> >> >>
> >> >> Are you trying to find the server-side control ID, as opposed to the
> >> >> "munged" client-side control ID...?
> >> >
> >> > yes Mark but this is the only way i know to get it thru javascript. is
> >> > there
> >> > another way?
> >>
> >> You don't need it...
> >>
> >> If you have a server-side control called DrpX and want to refer to it in
> >> client-side JavaScript, all you need is:
> >>
> >>
> >
> > can you use this if the textbox resides in a WebUserControl which in turn
> > is
> > on the .aspx page?
>
> Yes.
>
> > i tried document.getElementById('<% WebUserControl1_TextBox1 %'>)
> > but it won't compile, it says TextBox1 doesn't exist in this context.
>
> Firstly, you need the = sign, which is ASP.NET shorthand for Response.Write
>
> Secondly, you need to specify the .ClientID property of the control whose
> munged name you want to return...
>
>
> --
> Mark Rae
> ASP.NET MVP
> http://www.markrae.net
>
>