Home All Groups Group Topic Archive Search About
Author
13 Jun 2005 6:36 PM
Steve
I have created a Custom Control and I need to populate 2 fields with data
that I am grabbing from a control on the parent form.  I need to use
Javascript to grab the data on the parent form & populate the data in the
custom control.  The code that I have below get's the data but can't find the
control on the custom control.  Any ideas or proper direction would be
appreciated.

    sFName=document.Form1.fldFName.value;
    var NameField = document.getElementById(fldQFName);
    NameField.value = sFName;

Thanks!

Steve.

Author
13 Jun 2005 6:44 PM
Brock Allen
The ID in the client will be dynamically generated and might be different
than the exact ID you've assigned in your code. To determine what the ID
will be in the client browser use the ClientID property on the control in
the server. You'll have to incorporate that dynamically into your javascript
when calling getElementById().

-Brock
DevelopMentor
http://staff.develop.com/ballen



Show quoteHide quote
> I have created a Custom Control and I need to populate 2 fields with
> data that I am grabbing from a control on the parent form.  I need to
> use Javascript to grab the data on the parent form & populate the data
> in the custom control.  The code that I have below get's the data but
> can't find the control on the custom control.  Any ideas or proper
> direction would be appreciated.
>
> sFName=document.Form1.fldFName.value;
> var NameField = document.getElementById(fldQFName);
> NameField.value = sFName;
> Thanks!
>
> Steve.
>
Author
13 Jun 2005 6:53 PM
Steve
Forgive me for being a 'newbie' with Javascript... but how do I obtain the
ClientID property?  Could you possibly provide a short code snipet from what
your explaining?  Thank you very much for your help.

Show quoteHide quote
"Brock Allen" wrote:

> The ID in the client will be dynamically generated and might be different
> than the exact ID you've assigned in your code. To determine what the ID
> will be in the client browser use the ClientID property on the control in
> the server. You'll have to incorporate that dynamically into your javascript
> when calling getElementById().
>
> -Brock
> DevelopMentor
> http://staff.develop.com/ballen
>
>
>
> > I have created a Custom Control and I need to populate 2 fields with
> > data that I am grabbing from a control on the parent form.  I need to
> > use Javascript to grab the data on the parent form & populate the data
> > in the custom control.  The code that I have below get's the data but
> > can't find the control on the custom control.  Any ideas or proper
> > direction would be appreciated.
> >
> > sFName=document.Form1.fldFName.value;
> > var NameField = document.getElementById(fldQFName);
> > NameField.value = sFName;
> > Thanks!
> >
> > Steve.
> >
>
>
>
>
Author
13 Jun 2005 7:53 PM
Brock Allen
So do something like this in your server side code:

string js = "var control = doc.getElementById('{0}')";
js = String.Format(js, _myServerControl.ClientID);

You'd then need to somehow get the javascript in the 'js' variable into the
page. It's hard to advise given that I'm not sure what you're trying to do
exactly.

Another approach is to do this all in your ASPX, so taking your initial example
(assuming fldQFName is a server side control in your ASPX):

sFName=document.Form1.fldFName.value;
var NameField = document.getElementById(' <%= fldQFName.ClientID %> ');
NameField.value = sFName;

-Brock
DevelopMentor
http://staff.develop.com/ballen



Show quoteHide quote
> Forgive me for being a 'newbie' with Javascript... but how do I obtain
> the ClientID property?  Could you possibly provide a short code snipet
> from what your explaining?  Thank you very much for your help.
>
> "Brock Allen" wrote:
>
>> The ID in the client will be dynamically generated and might be
>> different than the exact ID you've assigned in your code. To
>> determine what the ID will be in the client browser use the ClientID
>> property on the control in the server. You'll have to incorporate
>> that dynamically into your javascript when calling getElementById().
>>
>> -Brock
>> DevelopMentor
>> http://staff.develop.com/ballen
>>> I have created a Custom Control and I need to populate 2 fields with
>>> data that I am grabbing from a control on the parent form.  I need
>>> to use Javascript to grab the data on the parent form & populate the
>>> data in the custom control.  The code that I have below get's the
>>> data but can't find the control on the custom control.  Any ideas or
>>> proper direction would be appreciated.
>>>
>>> sFName=document.Form1.fldFName.value;
>>> var NameField = document.getElementById(fldQFName);
>>> NameField.value = sFName;
>>> Thanks!
>>> Steve.
>>>
Author
13 Jun 2005 8:36 PM
Steve
So I have a Media Player object on my screen & I don't want the page to
refresh because it will cause my Media Player to refresh.... which is why I'm
not performing this operation on the server.  I'm trying to grab the First &
Last name fields becasue I need to copy those values to my user control. 
This was very easy to do on the server side...but it would cause a refresh of
the Media that was playing so this is why i'm looking at trying to perform
this operation on the client side.

I tried your option dvar NameField =
document.getElementById('<%=fldQFName.ClientID%>') but that returns an error:

Compiler Error Message: BC30390: 'Fibs20.QDriver.Protected Dim WithEvents
fldQFName As System.Web.UI.WebControls.TextBox' is not accessible in this
context because it is 'Protected'

Steve.

Show quoteHide quote
"Brock Allen" wrote:

> So do something like this in your server side code:
>
> string js = "var control = doc.getElementById('{0}')";
> js = String.Format(js, _myServerControl.ClientID);
>
> You'd then need to somehow get the javascript in the 'js' variable into the
> page. It's hard to advise given that I'm not sure what you're trying to do
> exactly.
>
> Another approach is to do this all in your ASPX, so taking your initial example
> (assuming fldQFName is a server side control in your ASPX):
>
> sFName=document.Form1.fldFName.value;
> var NameField = document.getElementById(' <%= fldQFName.ClientID %> ');
> NameField.value = sFName;
>
> -Brock
> DevelopMentor
> http://staff.develop.com/ballen
>
>
>
> > Forgive me for being a 'newbie' with Javascript... but how do I obtain
> > the ClientID property?  Could you possibly provide a short code snipet
> > from what your explaining?  Thank you very much for your help.
> >
> > "Brock Allen" wrote:
> >
> >> The ID in the client will be dynamically generated and might be
> >> different than the exact ID you've assigned in your code. To
> >> determine what the ID will be in the client browser use the ClientID
> >> property on the control in the server. You'll have to incorporate
> >> that dynamically into your javascript when calling getElementById().
> >>
> >> -Brock
> >> DevelopMentor
> >> http://staff.develop.com/ballen
> >>> I have created a Custom Control and I need to populate 2 fields with
> >>> data that I am grabbing from a control on the parent form.  I need
> >>> to use Javascript to grab the data on the parent form & populate the
> >>> data in the custom control.  The code that I have below get's the
> >>> data but can't find the control on the custom control.  Any ideas or
> >>> proper direction would be appreciated.
> >>>
> >>> sFName=document.Form1.fldFName.value;
> >>> var NameField = document.getElementById(fldQFName);
> >>> NameField.value = sFName;
> >>> Thanks!
> >>> Steve.
> >>>
>
>
>
>
Author
13 Jun 2005 8:53 PM
Brock Allen
If the fldQFName is a control in the same ASPX (or ASCX) where you're doing
the script, then I'm not sure whay you have that compiler problem.

-Brock
DevelopMentor
http://staff.develop.com/ballen



Show quoteHide quote
> So I have a Media Player object on my screen & I don't want the page
> to refresh because it will cause my Media Player to refresh.... which
> is why I'm not performing this operation on the server.  I'm trying to
> grab the First & Last name fields becasue I need to copy those values
> to my user control.  This was very easy to do on the server side...but
> it would cause a refresh of the Media that was playing so this is why
> i'm looking at trying to perform this operation on the client side.
>
> I tried your option dvar NameField =
> document.getElementById('<%=fldQFName.ClientID%>') but that returns an
> error:
>
> Compiler Error Message: BC30390: 'Fibs20.QDriver.Protected Dim
> WithEvents fldQFName As System.Web.UI.WebControls.TextBox' is not
> accessible in this context because it is 'Protected'
>
> Steve.
>
> "Brock Allen" wrote:
>
>> So do something like this in your server side code:
>>
>> string js = "var control = doc.getElementById('{0}')"; js =
>> String.Format(js, _myServerControl.ClientID);
>>
>> You'd then need to somehow get the javascript in the 'js' variable
>> into the page. It's hard to advise given that I'm not sure what
>> you're trying to do exactly.
>>
>> Another approach is to do this all in your ASPX, so taking your
>> initial example (assuming fldQFName is a server side control in your
>> ASPX):
>>
>> sFName=document.Form1.fldFName.value;
>> var NameField = document.getElementById(' <%= fldQFName.ClientID %>
>> ');
>> NameField.value = sFName;
>> -Brock
>> DevelopMentor
>> http://staff.develop.com/ballen
>>> Forgive me for being a 'newbie' with Javascript... but how do I
>>> obtain the ClientID property?  Could you possibly provide a short
>>> code snipet from what your explaining?  Thank you very much for your
>>> help.
>>>
>>> "Brock Allen" wrote:
>>>
>>>> The ID in the client will be dynamically generated and might be
>>>> different than the exact ID you've assigned in your code. To
>>>> determine what the ID will be in the client browser use the
>>>> ClientID property on the control in the server. You'll have to
>>>> incorporate that dynamically into your javascript when calling
>>>> getElementById().
>>>>
>>>> -Brock
>>>> DevelopMentor
>>>> http://staff.develop.com/ballen
>>>>> I have created a Custom Control and I need to populate 2 fields
>>>>> with data that I am grabbing from a control on the parent form.  I
>>>>> need to use Javascript to grab the data on the parent form &
>>>>> populate the data in the custom control.  The code that I have
>>>>> below get's the data but can't find the control on the custom
>>>>> control.  Any ideas or proper direction would be appreciated.
>>>>>
>>>>> sFName=document.Form1.fldFName.value;
>>>>> var NameField = document.getElementById(fldQFName);
>>>>> NameField.value = sFName;
>>>>> Thanks!
>>>>> Steve.
Author
13 Jun 2005 9:09 PM
Steve
My structure is like this:
-  aspx page
   -  1st ascx control
   -  2nd ascx control

The Media & the initial first & last name fields are on the aspx page... i'm
trying to copy the first & last names from the aspx page & populate the 1st
ascx control first & last names.

Thank you for your input...at least I've got a direction to go :)

Steve.

Show quoteHide quote
"Brock Allen" wrote:

> If the fldQFName is a control in the same ASPX (or ASCX) where you're doing
> the script, then I'm not sure whay you have that compiler problem.
>
> -Brock
> DevelopMentor
> http://staff.develop.com/ballen
>
>
>
> > So I have a Media Player object on my screen & I don't want the page
> > to refresh because it will cause my Media Player to refresh.... which
> > is why I'm not performing this operation on the server.  I'm trying to
> > grab the First & Last name fields becasue I need to copy those values
> > to my user control.  This was very easy to do on the server side...but
> > it would cause a refresh of the Media that was playing so this is why
> > i'm looking at trying to perform this operation on the client side.
> >
> > I tried your option dvar NameField =
> > document.getElementById('<%=fldQFName.ClientID%>') but that returns an
> > error:
> >
> > Compiler Error Message: BC30390: 'Fibs20.QDriver.Protected Dim
> > WithEvents fldQFName As System.Web.UI.WebControls.TextBox' is not
> > accessible in this context because it is 'Protected'
> >
> > Steve.
> >
> > "Brock Allen" wrote:
> >
> >> So do something like this in your server side code:
> >>
> >> string js = "var control = doc.getElementById('{0}')"; js =
> >> String.Format(js, _myServerControl.ClientID);
> >>
> >> You'd then need to somehow get the javascript in the 'js' variable
> >> into the page. It's hard to advise given that I'm not sure what
> >> you're trying to do exactly.
> >>
> >> Another approach is to do this all in your ASPX, so taking your
> >> initial example (assuming fldQFName is a server side control in your
> >> ASPX):
> >>
> >> sFName=document.Form1.fldFName.value;
> >> var NameField = document.getElementById(' <%= fldQFName.ClientID %>
> >> ');
> >> NameField.value = sFName;
> >> -Brock
> >> DevelopMentor
> >> http://staff.develop.com/ballen
> >>> Forgive me for being a 'newbie' with Javascript... but how do I
> >>> obtain the ClientID property?  Could you possibly provide a short
> >>> code snipet from what your explaining?  Thank you very much for your
> >>> help.
> >>>
> >>> "Brock Allen" wrote:
> >>>
> >>>> The ID in the client will be dynamically generated and might be
> >>>> different than the exact ID you've assigned in your code. To
> >>>> determine what the ID will be in the client browser use the
> >>>> ClientID property on the control in the server. You'll have to
> >>>> incorporate that dynamically into your javascript when calling
> >>>> getElementById().
> >>>>
> >>>> -Brock
> >>>> DevelopMentor
> >>>> http://staff.develop.com/ballen
> >>>>> I have created a Custom Control and I need to populate 2 fields
> >>>>> with data that I am grabbing from a control on the parent form.  I
> >>>>> need to use Javascript to grab the data on the parent form &
> >>>>> populate the data in the custom control.  The code that I have
> >>>>> below get's the data but can't find the control on the custom
> >>>>> control.  Any ideas or proper direction would be appreciated.
> >>>>>
> >>>>> sFName=document.Form1.fldFName.value;
> >>>>> var NameField = document.getElementById(fldQFName);
> >>>>> NameField.value = sFName;
> >>>>> Thanks!
> >>>>> Steve.
>
>
>
>
Author
14 Jun 2005 3:01 AM
Sam Samnah
isn't the ClientID hidden?
Couldn't you just use this.ClientID?

Show quoteHide quote
"Steve" <St***@discussions.microsoft.com> wrote in message
news:1520D867-BFC0-4330-8EDE-B8FC78424CCC@microsoft.com...
> My structure is like this:
> -  aspx page
>   -  1st ascx control
>   -  2nd ascx control
>
> The Media & the initial first & last name fields are on the aspx page...
> i'm
> trying to copy the first & last names from the aspx page & populate the
> 1st
> ascx control first & last names.
>
> Thank you for your input...at least I've got a direction to go :)
>
> Steve.
>
> "Brock Allen" wrote:
>
>> If the fldQFName is a control in the same ASPX (or ASCX) where you're
>> doing
>> the script, then I'm not sure whay you have that compiler problem.
>>
>> -Brock
>> DevelopMentor
>> http://staff.develop.com/ballen
>>
>>
>>
>> > So I have a Media Player object on my screen & I don't want the page
>> > to refresh because it will cause my Media Player to refresh.... which
>> > is why I'm not performing this operation on the server.  I'm trying to
>> > grab the First & Last name fields becasue I need to copy those values
>> > to my user control.  This was very easy to do on the server side...but
>> > it would cause a refresh of the Media that was playing so this is why
>> > i'm looking at trying to perform this operation on the client side.
>> >
>> > I tried your option dvar NameField =
>> > document.getElementById('<%=fldQFName.ClientID%>') but that returns an
>> > error:
>> >
>> > Compiler Error Message: BC30390: 'Fibs20.QDriver.Protected Dim
>> > WithEvents fldQFName As System.Web.UI.WebControls.TextBox' is not
>> > accessible in this context because it is 'Protected'
>> >
>> > Steve.
>> >
>> > "Brock Allen" wrote:
>> >
>> >> So do something like this in your server side code:
>> >>
>> >> string js = "var control = doc.getElementById('{0}')"; js =
>> >> String.Format(js, _myServerControl.ClientID);
>> >>
>> >> You'd then need to somehow get the javascript in the 'js' variable
>> >> into the page. It's hard to advise given that I'm not sure what
>> >> you're trying to do exactly.
>> >>
>> >> Another approach is to do this all in your ASPX, so taking your
>> >> initial example (assuming fldQFName is a server side control in your
>> >> ASPX):
>> >>
>> >> sFName=document.Form1.fldFName.value;
>> >> var NameField = document.getElementById(' <%= fldQFName.ClientID %>
>> >> ');
>> >> NameField.value = sFName;
>> >> -Brock
>> >> DevelopMentor
>> >> http://staff.develop.com/ballen
>> >>> Forgive me for being a 'newbie' with Javascript... but how do I
>> >>> obtain the ClientID property?  Could you possibly provide a short
>> >>> code snipet from what your explaining?  Thank you very much for your
>> >>> help.
>> >>>
>> >>> "Brock Allen" wrote:
>> >>>
>> >>>> The ID in the client will be dynamically generated and might be
>> >>>> different than the exact ID you've assigned in your code. To
>> >>>> determine what the ID will be in the client browser use the
>> >>>> ClientID property on the control in the server. You'll have to
>> >>>> incorporate that dynamically into your javascript when calling
>> >>>> getElementById().
>> >>>>
>> >>>> -Brock
>> >>>> DevelopMentor
>> >>>> http://staff.develop.com/ballen
>> >>>>> I have created a Custom Control and I need to populate 2 fields
>> >>>>> with data that I am grabbing from a control on the parent form.  I
>> >>>>> need to use Javascript to grab the data on the parent form &
>> >>>>> populate the data in the custom control.  The code that I have
>> >>>>> below get's the data but can't find the control on the custom
>> >>>>> control.  Any ideas or proper direction would be appreciated.
>> >>>>>
>> >>>>> sFName=document.Form1.fldFName.value;
>> >>>>> var NameField = document.getElementById(fldQFName);
>> >>>>> NameField.value = sFName;
>> >>>>> Thanks!
>> >>>>> Steve.
>>
>>
>>
>>