javascript string manipulation
am 09.04.2008 17:02:00 von rodcharhey 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
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
"rodchar"
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
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
yes Mark but this is the only way i know to get it thru javascript. is there
another way?
"Mark Rae [MVP]" wrote:
> "rodchar"
> 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
>
>
use
DrpX.ClientID
or sometimes
DrpX.UniqueID
depending on what you need name or id of the control...
George.
"rodchar"
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"
>> 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
>>
>>
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"
> 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"
> >> 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
> >>
> >>
>
>
>
"rodchar"
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
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"
> 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
>
>
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
"rodchar"
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
thanks Mark and everyone for this very helpful thread,
rod.
"Mark Rae [MVP]" wrote:
> "rodchar"
> 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
>
>