Get DropDownList.SelectedValue from Page_PreInit Event
am 12.01.2008 02:55:22 von redhairIs it possible to get DropDownList.SelectedValue in Page_PreInit() event
during the postback?
Is it possible to get DropDownList.SelectedValue in Page_PreInit() event
during the postback?
Unfortunately I believe the answer is no. Is there a reason you need this
value before the page is initialized?
You could potentially inject the value into a cookie using JavaScript using
the OnSubmit event of your form, then read that using the
HttpContext.Current.Request.Cookies collection to retrieve your value upon
post-back. I believe the HttpRequest stack has been created by then and upon
calling the OnPreInit method of your page, has built these values from the
request headers.
--
Chad Scharf
_______________________________
http://www.chadscharf.com
"Redhairs" wrote:
> Is it possible to get DropDownList.SelectedValue in Page_PreInit() event
> during the postback?
>
>
>
Howdy,
Why using cookie, wouldn't be easier just by using
string selectedValue = Request.Form[yourDropDown.UniqueID]
?
--
Milosz
"Chad Scharf" wrote:
> Unfortunately I believe the answer is no. Is there a reason you need this
> value before the page is initialized?
>
> You could potentially inject the value into a cookie using JavaScript using
> the OnSubmit event of your form, then read that using the
> HttpContext.Current.Request.Cookies collection to retrieve your value upon
> post-back. I believe the HttpRequest stack has been created by then and upon
> calling the OnPreInit method of your page, has built these values from the
> request headers.
>
> --
> Chad Scharf
> _______________________________
> http://www.chadscharf.com
>
>
> "Redhairs" wrote:
>
> > Is it possible to get DropDownList.SelectedValue in Page_PreInit() event
> > during the postback?
> >
> >
> >
Yes, that would be easier. Sorry, I typically never use Request.Form and
forgot about it.
Is the UniqueID available though in the Page_PreInit event, seeing as the
control tree has not yet been built, it would be difficult for the Page to
calculate the UniqueID, and typically the Control instance would be null as
well no?
--
Chad Scharf
_______________________________
http://www.chadscharf.com
"Milosz Skalecki [MCAD]" wrote:
> Howdy,
>
> Why using cookie, wouldn't be easier just by using
> string selectedValue = Request.Form[yourDropDown.UniqueID]
> ?
>
>
> --
> Milosz
>
>
> "Chad Scharf" wrote:
>
> > Unfortunately I believe the answer is no. Is there a reason you need this
> > value before the page is initialized?
> >
> > You could potentially inject the value into a cookie using JavaScript using
> > the OnSubmit event of your form, then read that using the
> > HttpContext.Current.Request.Cookies collection to retrieve your value upon
> > post-back. I believe the HttpRequest stack has been created by then and upon
> > calling the OnPreInit method of your page, has built these values from the
> > request headers.
> >
> > --
> > Chad Scharf
> > _______________________________
> > http://www.chadscharf.com
> >
> >
> > "Redhairs" wrote:
> >
> > > Is it possible to get DropDownList.SelectedValue in Page_PreInit() event
> > > during the postback?
> > >
> > >
> > >
Hi Chad,
The control tree is already created in PreInit event, as the aspx page
compiler puts all the declarations into FrameworkInitialize() method which is
called from Page.ProcessRequest (member of the IHttpHandler interface) (have
a look at the content of your website's asp.net folder, especially at
compiled pages). Therefore, it's safe to run the code:
Request.Form[ddl.uniqueID]
Regards
--
Milosz
"Chad Scharf" wrote:
> Yes, that would be easier. Sorry, I typically never use Request.Form and
> forgot about it.
>
> Is the UniqueID available though in the Page_PreInit event, seeing as the
> control tree has not yet been built, it would be difficult for the Page to
> calculate the UniqueID, and typically the Control instance would be null as
> well no?
>
> --
> Chad Scharf
> _______________________________
> http://www.chadscharf.com
>
>
> "Milosz Skalecki [MCAD]" wrote:
>
> > Howdy,
> >
> > Why using cookie, wouldn't be easier just by using
> > string selectedValue = Request.Form[yourDropDown.UniqueID]
> > ?
> >
> >
> > --
> > Milosz
> >
> >
> > "Chad Scharf" wrote:
> >
> > > Unfortunately I believe the answer is no. Is there a reason you need this
> > > value before the page is initialized?
> > >
> > > You could potentially inject the value into a cookie using JavaScript using
> > > the OnSubmit event of your form, then read that using the
> > > HttpContext.Current.Request.Cookies collection to retrieve your value upon
> > > post-back. I believe the HttpRequest stack has been created by then and upon
> > > calling the OnPreInit method of your page, has built these values from the
> > > request headers.
> > >
> > > --
> > > Chad Scharf
> > > _______________________________
> > > http://www.chadscharf.com
> > >
> > >
> > > "Redhairs" wrote:
> > >
> > > > Is it possible to get DropDownList.SelectedValue in Page_PreInit() event
> > > > during the postback?
> > > >
> > > >
> > > >
It doesn't work and return error msg "Object reference not set to an
instance of an object"
"Milosz Skalecki [MCAD]"
news:EF293811-3B1C-4454-B199-FFBD99D95D4E@microsoft.com...
> Hi Chad,
>
> The control tree is already created in PreInit event, as the aspx page
> compiler puts all the declarations into FrameworkInitialize() method which
> is
> called from Page.ProcessRequest (member of the IHttpHandler interface)
> (have
> a look at the content of your website's asp.net folder, especially at
> compiled pages). Therefore, it's safe to run the code:
> Request.Form[ddl.uniqueID]
>
> Regards
> --
> Milosz
>
>
> "Chad Scharf" wrote:
>
>> Yes, that would be easier. Sorry, I typically never use Request.Form and
>> forgot about it.
>>
>> Is the UniqueID available though in the Page_PreInit event, seeing as the
>> control tree has not yet been built, it would be difficult for the Page
>> to
>> calculate the UniqueID, and typically the Control instance would be null
>> as
>> well no?
>>
>> --
>> Chad Scharf
>> _______________________________
>> http://www.chadscharf.com
>>
>>
>> "Milosz Skalecki [MCAD]" wrote:
>>
>> > Howdy,
>> >
>> > Why using cookie, wouldn't be easier just by using
>> > string selectedValue = Request.Form[yourDropDown.UniqueID]
>> > ?
>> >
>> >
>> > --
>> > Milosz
>> >
>> >
>> > "Chad Scharf" wrote:
>> >
>> > > Unfortunately I believe the answer is no. Is there a reason you need
>> > > this
>> > > value before the page is initialized?
>> > >
>> > > You could potentially inject the value into a cookie using JavaScript
>> > > using
>> > > the OnSubmit event of your form, then read that using the
>> > > HttpContext.Current.Request.Cookies collection to retrieve your value
>> > > upon
>> > > post-back. I believe the HttpRequest stack has been created by then
>> > > and upon
>> > > calling the OnPreInit method of your page, has built these values
>> > > from the
>> > > request headers.
>> > >
>> > > --
>> > > Chad Scharf
>> > > _______________________________
>> > > http://www.chadscharf.com
>> > >
>> > >
>> > > "Redhairs" wrote:
>> > >
>> > > > Is it possible to get DropDownList.SelectedValue in Page_PreInit()
>> > > > event
>> > > > during the postback?
>> > > >
>> > > >
>> > > >
Hi Redhairs,
I checked it and it works fine. Are you by any chance create this control
dynamically or drop down list is placed inside a tamplated control? Could you
please pase some code?
Regards
--
Milosz
"Redhairs" wrote:
> It doesn't work and return error msg "Object reference not set to an
> instance of an object"
> "Milosz Skalecki [MCAD]"
> news:EF293811-3B1C-4454-B199-FFBD99D95D4E@microsoft.com...
> > Hi Chad,
> >
> > The control tree is already created in PreInit event, as the aspx page
> > compiler puts all the declarations into FrameworkInitialize() method which
> > is
> > called from Page.ProcessRequest (member of the IHttpHandler interface)
> > (have
> > a look at the content of your website's asp.net folder, especially at
> > compiled pages). Therefore, it's safe to run the code:
> > Request.Form[ddl.uniqueID]
> >
> > Regards
> > --
> > Milosz
> >
> >
> > "Chad Scharf" wrote:
> >
> >> Yes, that would be easier. Sorry, I typically never use Request.Form and
> >> forgot about it.
> >>
> >> Is the UniqueID available though in the Page_PreInit event, seeing as the
> >> control tree has not yet been built, it would be difficult for the Page
> >> to
> >> calculate the UniqueID, and typically the Control instance would be null
> >> as
> >> well no?
> >>
> >> --
> >> Chad Scharf
> >> _______________________________
> >> http://www.chadscharf.com
> >>
> >>
> >> "Milosz Skalecki [MCAD]" wrote:
> >>
> >> > Howdy,
> >> >
> >> > Why using cookie, wouldn't be easier just by using
> >> > string selectedValue = Request.Form[yourDropDown.UniqueID]
> >> > ?
> >> >
> >> >
> >> > --
> >> > Milosz
> >> >
> >> >
> >> > "Chad Scharf" wrote:
> >> >
> >> > > Unfortunately I believe the answer is no. Is there a reason you need
> >> > > this
> >> > > value before the page is initialized?
> >> > >
> >> > > You could potentially inject the value into a cookie using JavaScript
> >> > > using
> >> > > the OnSubmit event of your form, then read that using the
> >> > > HttpContext.Current.Request.Cookies collection to retrieve your value
> >> > > upon
> >> > > post-back. I believe the HttpRequest stack has been created by then
> >> > > and upon
> >> > > calling the OnPreInit method of your page, has built these values
> >> > > from the
> >> > > request headers.
> >> > >
> >> > > --
> >> > > Chad Scharf
> >> > > _______________________________
> >> > > http://www.chadscharf.com
> >> > >
> >> > >
> >> > > "Redhairs" wrote:
> >> > >
> >> > > > Is it possible to get DropDownList.SelectedValue in Page_PreInit()
> >> > > > event
> >> > > > during the postback?
> >> > > >
> >> > > >
> >> > > >
>
>
>
Yes, I use use the master page so the DropDownList was placed in the Content
control,
how to solve this problem?
Btw, waht's the difference between ClientID and UniqueID?
"Milosz Skalecki [MCAD]"
news:BC6247CA-61E5-4908-9C04-C5FF9782BB89@microsoft.com...
> Hi Redhairs,
>
> I checked it and it works fine. Are you by any chance create this control
> dynamically or drop down list is placed inside a tamplated control? Could
> you
> please pase some code?
>
> Regards
> --
> Milosz
>
>
> "Redhairs" wrote:
>
>> It doesn't work and return error msg "Object reference not set to an
>> instance of an object"
>> "Milosz Skalecki [MCAD]"
>> news:EF293811-3B1C-4454-B199-FFBD99D95D4E@microsoft.com...
>> > Hi Chad,
>> >
>> > The control tree is already created in PreInit event, as the aspx page
>> > compiler puts all the declarations into FrameworkInitialize() method
>> > which
>> > is
>> > called from Page.ProcessRequest (member of the IHttpHandler interface)
>> > (have
>> > a look at the content of your website's asp.net folder, especially at
>> > compiled pages). Therefore, it's safe to run the code:
>> > Request.Form[ddl.uniqueID]
>> >
>> > Regards
>> > --
>> > Milosz
>> >
>> >
>> > "Chad Scharf" wrote:
>> >
>> >> Yes, that would be easier. Sorry, I typically never use Request.Form
>> >> and
>> >> forgot about it.
>> >>
>> >> Is the UniqueID available though in the Page_PreInit event, seeing as
>> >> the
>> >> control tree has not yet been built, it would be difficult for the
>> >> Page
>> >> to
>> >> calculate the UniqueID, and typically the Control instance would be
>> >> null
>> >> as
>> >> well no?
>> >>
>> >> --
>> >> Chad Scharf
>> >> _______________________________
>> >> http://www.chadscharf.com
>> >>
>> >>
>> >> "Milosz Skalecki [MCAD]" wrote:
>> >>
>> >> > Howdy,
>> >> >
>> >> > Why using cookie, wouldn't be easier just by using
>> >> > string selectedValue = Request.Form[yourDropDown.UniqueID]
>> >> > ?
>> >> >
>> >> >
>> >> > --
>> >> > Milosz
>> >> >
>> >> >
>> >> > "Chad Scharf" wrote:
>> >> >
>> >> > > Unfortunately I believe the answer is no. Is there a reason you
>> >> > > need
>> >> > > this
>> >> > > value before the page is initialized?
>> >> > >
>> >> > > You could potentially inject the value into a cookie using
>> >> > > JavaScript
>> >> > > using
>> >> > > the OnSubmit event of your form, then read that using the
>> >> > > HttpContext.Current.Request.Cookies collection to retrieve your
>> >> > > value
>> >> > > upon
>> >> > > post-back. I believe the HttpRequest stack has been created by
>> >> > > then
>> >> > > and upon
>> >> > > calling the OnPreInit method of your page, has built these values
>> >> > > from the
>> >> > > request headers.
>> >> > >
>> >> > > --
>> >> > > Chad Scharf
>> >> > > _______________________________
>> >> > > http://www.chadscharf.com
>> >> > >
>> >> > >
>> >> > > "Redhairs" wrote:
>> >> > >
>> >> > > > Is it possible to get DropDownList.SelectedValue in
>> >> > > > Page_PreInit()
>> >> > > > event
>> >> > > > during the postback?
>> >> > > >
>> >> > > >
>> >> > > >
>>
>>
>>
Howdy,
In this case (masterpage) you have to manually find the control as it has
not been referenced yet (but it has been instantiated in the contrnt place
holder):
string selectedValue =
Request.Form[Master.FindControl("placeholdername").FindContr ol("ddlID").UniqueID];
It's quite nasty, so my question is why would you need that? The difference
bewteen UniqueID and ClientID is the first is used as "name" attribute for
input controls and it consists of ID + parents ID (simpifying) separated by a
dollar character, whilst ClientID is used as "id" attribute of all the html
elements that are generated by web controls/html controls with runat=server
separated by underscore char. For more info check this out:
http://www.shanebauer.com/Weblog/PermaLink,guid,488f7bb3-dac 8-400b-aacf-e94d4da9b533.aspx
--
Milosz
"Redhairs" wrote:
> Yes, I use use the master page so the DropDownList was placed in the Content
> control,
> how to solve this problem?
> Btw, waht's the difference between ClientID and UniqueID?
>
>
> "Milosz Skalecki [MCAD]"
> news:BC6247CA-61E5-4908-9C04-C5FF9782BB89@microsoft.com...
> > Hi Redhairs,
> >
> > I checked it and it works fine. Are you by any chance create this control
> > dynamically or drop down list is placed inside a tamplated control? Could
> > you
> > please pase some code?
> >
> > Regards
> > --
> > Milosz
> >
> >
> > "Redhairs" wrote:
> >
> >> It doesn't work and return error msg "Object reference not set to an
> >> instance of an object"
> >> "Milosz Skalecki [MCAD]"
> >> news:EF293811-3B1C-4454-B199-FFBD99D95D4E@microsoft.com...
> >> > Hi Chad,
> >> >
> >> > The control tree is already created in PreInit event, as the aspx page
> >> > compiler puts all the declarations into FrameworkInitialize() method
> >> > which
> >> > is
> >> > called from Page.ProcessRequest (member of the IHttpHandler interface)
> >> > (have
> >> > a look at the content of your website's asp.net folder, especially at
> >> > compiled pages). Therefore, it's safe to run the code:
> >> > Request.Form[ddl.uniqueID]
> >> >
> >> > Regards
> >> > --
> >> > Milosz
> >> >
> >> >
> >> > "Chad Scharf" wrote:
> >> >
> >> >> Yes, that would be easier. Sorry, I typically never use Request.Form
> >> >> and
> >> >> forgot about it.
> >> >>
> >> >> Is the UniqueID available though in the Page_PreInit event, seeing as
> >> >> the
> >> >> control tree has not yet been built, it would be difficult for the
> >> >> Page
> >> >> to
> >> >> calculate the UniqueID, and typically the Control instance would be
> >> >> null
> >> >> as
> >> >> well no?
> >> >>
> >> >> --
> >> >> Chad Scharf
> >> >> _______________________________
> >> >> http://www.chadscharf.com
> >> >>
> >> >>
> >> >> "Milosz Skalecki [MCAD]" wrote:
> >> >>
> >> >> > Howdy,
> >> >> >
> >> >> > Why using cookie, wouldn't be easier just by using
> >> >> > string selectedValue = Request.Form[yourDropDown.UniqueID]
> >> >> > ?
> >> >> >
> >> >> >
> >> >> > --
> >> >> > Milosz
> >> >> >
> >> >> >
> >> >> > "Chad Scharf" wrote:
> >> >> >
> >> >> > > Unfortunately I believe the answer is no. Is there a reason you
> >> >> > > need
> >> >> > > this
> >> >> > > value before the page is initialized?
> >> >> > >
> >> >> > > You could potentially inject the value into a cookie using
> >> >> > > JavaScript
> >> >> > > using
> >> >> > > the OnSubmit event of your form, then read that using the
> >> >> > > HttpContext.Current.Request.Cookies collection to retrieve your
> >> >> > > value
> >> >> > > upon
> >> >> > > post-back. I believe the HttpRequest stack has been created by
> >> >> > > then
> >> >> > > and upon
> >> >> > > calling the OnPreInit method of your page, has built these values
> >> >> > > from the
> >> >> > > request headers.
> >> >> > >
> >> >> > > --
> >> >> > > Chad Scharf
> >> >> > > _______________________________
> >> >> > > http://www.chadscharf.com
> >> >> > >
> >> >> > >
> >> >> > > "Redhairs" wrote:
> >> >> > >
> >> >> > > > Is it possible to get DropDownList.SelectedValue in
> >> >> > > > Page_PreInit()
> >> >> > > > event
> >> >> > > > during the postback?
> >> >> > > >
> >> >> > > >
> >> >> > > >
> >>
> >>
> >>
>
>
>
Thanks for your quick response.
I can find the
Master.FindControl("placeholdername").FindControl("ddlID").U niqueID in
Page_PreInit()
but still get "Object reference not set to an instance of an object" if try
to access
Request.Form[Master.FindControl("placeholdername").FindContr ol("ddlID").UniqueID];
But the ddlID.UnigueID is one of the keys of Request.Form collection.
Can't figure out why.
"Milosz Skalecki [MCAD]"
news:9CB89864-FA79-441B-A3AF-DD636BB84220@microsoft.com...
> Howdy,
>
> In this case (masterpage) you have to manually find the control as it has
> not been referenced yet (but it has been instantiated in the contrnt place
> holder):
>
> string selectedValue =
> Request.Form[Master.FindControl("placeholdername").FindContr ol("ddlID").UniqueID];
>
> It's quite nasty, so my question is why would you need that? The
> difference
> bewteen UniqueID and ClientID is the first is used as "name" attribute for
> input controls and it consists of ID + parents ID (simpifying) separated
> by a
> dollar character, whilst ClientID is used as "id" attribute of all the
> html
> elements that are generated by web controls/html controls with
> runat=server
> separated by underscore char. For more info check this out:
> http://www.shanebauer.com/Weblog/PermaLink,guid,488f7bb3-dac 8-400b-aacf-e94d4da9b533.aspx
> --
> Milosz
>
>
> "Redhairs" wrote:
>
>> Yes, I use use the master page so the DropDownList was placed in the
>> Content
>> control,
>> how to solve this problem?
>> Btw, waht's the difference between ClientID and UniqueID?
>>
>>
>> "Milosz Skalecki [MCAD]"
>> news:BC6247CA-61E5-4908-9C04-C5FF9782BB89@microsoft.com...
>> > Hi Redhairs,
>> >
>> > I checked it and it works fine. Are you by any chance create this
>> > control
>> > dynamically or drop down list is placed inside a tamplated control?
>> > Could
>> > you
>> > please pase some code?
>> >
>> > Regards
>> > --
>> > Milosz
>> >
>> >
>> > "Redhairs" wrote:
>> >
>> >> It doesn't work and return error msg "Object reference not set to an
>> >> instance of an object"
>> >> "Milosz Skalecki [MCAD]"
>> >> news:EF293811-3B1C-4454-B199-FFBD99D95D4E@microsoft.com...
>> >> > Hi Chad,
>> >> >
>> >> > The control tree is already created in PreInit event, as the aspx
>> >> > page
>> >> > compiler puts all the declarations into FrameworkInitialize() method
>> >> > which
>> >> > is
>> >> > called from Page.ProcessRequest (member of the IHttpHandler
>> >> > interface)
>> >> > (have
>> >> > a look at the content of your website's asp.net folder, especially
>> >> > at
>> >> > compiled pages). Therefore, it's safe to run the code:
>> >> > Request.Form[ddl.uniqueID]
>> >> >
>> >> > Regards
>> >> > --
>> >> > Milosz
>> >> >
>> >> >
>> >> > "Chad Scharf" wrote:
>> >> >
>> >> >> Yes, that would be easier. Sorry, I typically never use
>> >> >> Request.Form
>> >> >> and
>> >> >> forgot about it.
>> >> >>
>> >> >> Is the UniqueID available though in the Page_PreInit event, seeing
>> >> >> as
>> >> >> the
>> >> >> control tree has not yet been built, it would be difficult for the
>> >> >> Page
>> >> >> to
>> >> >> calculate the UniqueID, and typically the Control instance would be
>> >> >> null
>> >> >> as
>> >> >> well no?
>> >> >>
>> >> >> --
>> >> >> Chad Scharf
>> >> >> _______________________________
>> >> >> http://www.chadscharf.com
>> >> >>
>> >> >>
>> >> >> "Milosz Skalecki [MCAD]" wrote:
>> >> >>
>> >> >> > Howdy,
>> >> >> >
>> >> >> > Why using cookie, wouldn't be easier just by using
>> >> >> > string selectedValue = Request.Form[yourDropDown.UniqueID]
>> >> >> > ?
>> >> >> >
>> >> >> >
>> >> >> > --
>> >> >> > Milosz
>> >> >> >
>> >> >> >
>> >> >> > "Chad Scharf" wrote:
>> >> >> >
>> >> >> > > Unfortunately I believe the answer is no. Is there a reason you
>> >> >> > > need
>> >> >> > > this
>> >> >> > > value before the page is initialized?
>> >> >> > >
>> >> >> > > You could potentially inject the value into a cookie using
>> >> >> > > JavaScript
>> >> >> > > using
>> >> >> > > the OnSubmit event of your form, then read that using the
>> >> >> > > HttpContext.Current.Request.Cookies collection to retrieve your
>> >> >> > > value
>> >> >> > > upon
>> >> >> > > post-back. I believe the HttpRequest stack has been created by
>> >> >> > > then
>> >> >> > > and upon
>> >> >> > > calling the OnPreInit method of your page, has built these
>> >> >> > > values
>> >> >> > > from the
>> >> >> > > request headers.
>> >> >> > >
>> >> >> > > --
>> >> >> > > Chad Scharf
>> >> >> > > _______________________________
>> >> >> > > http://www.chadscharf.com
>> >> >> > >
>> >> >> > >
>> >> >> > > "Redhairs" wrote:
>> >> >> > >
>> >> >> > > > Is it possible to get DropDownList.SelectedValue in
>> >> >> > > > Page_PreInit()
>> >> >> > > > event
>> >> >> > > > during the postback?
>> >> >> > > >
>> >> >> > > >
>> >> >> > > >
>> >>
>> >>
>> >>
>>
>>
>>
The source codes are as below, the page is inherited from one base class
Test.aspx:
Test.aspx.cs
void Page_PreInit(object sender, EventArg e)
{
DropDownList _theDDL = (DropDownList)
Master.FindControl("TheHolder").FindControl("langSelection") ;
if (_theDDL != null)
Response.Write(Request.Form[_theDDL.UnigueID]); // null Object
reference err here
}
"Milosz Skalecki [MCAD]"
news:9CB89864-FA79-441B-A3AF-DD636BB84220@microsoft.com...
> Howdy,
>
> In this case (masterpage) you have to manually find the control as it has
> not been referenced yet (but it has been instantiated in the contrnt place
> holder):
>
> string selectedValue =
> Request.Form[Master.FindControl("placeholdername").FindContr ol("ddlID").UniqueID];
>
> It's quite nasty, so my question is why would you need that? The
> difference
> bewteen UniqueID and ClientID is the first is used as "name" attribute for
> input controls and it consists of ID + parents ID (simpifying) separated
> by a
> dollar character, whilst ClientID is used as "id" attribute of all the
> html
> elements that are generated by web controls/html controls with
> runat=server
> separated by underscore char. For more info check this out:
> http://www.shanebauer.com/Weblog/PermaLink,guid,488f7bb3-dac 8-400b-aacf-e94d4da9b533.aspx
> --
> Milosz
>
>
> "Redhairs" wrote:
>
>> Yes, I use use the master page so the DropDownList was placed in the
>> Content
>> control,
>> how to solve this problem?
>> Btw, waht's the difference between ClientID and UniqueID?
>>
>>
>> "Milosz Skalecki [MCAD]"
>> news:BC6247CA-61E5-4908-9C04-C5FF9782BB89@microsoft.com...
>> > Hi Redhairs,
>> >
>> > I checked it and it works fine. Are you by any chance create this
>> > control
>> > dynamically or drop down list is placed inside a tamplated control?
>> > Could
>> > you
>> > please pase some code?
>> >
>> > Regards
>> > --
>> > Milosz
>> >
>> >
>> > "Redhairs" wrote:
>> >
>> >> It doesn't work and return error msg "Object reference not set to an
>> >> instance of an object"
>> >> "Milosz Skalecki [MCAD]"
>> >> news:EF293811-3B1C-4454-B199-FFBD99D95D4E@microsoft.com...
>> >> > Hi Chad,
>> >> >
>> >> > The control tree is already created in PreInit event, as the aspx
>> >> > page
>> >> > compiler puts all the declarations into FrameworkInitialize() method
>> >> > which
>> >> > is
>> >> > called from Page.ProcessRequest (member of the IHttpHandler
>> >> > interface)
>> >> > (have
>> >> > a look at the content of your website's asp.net folder, especially
>> >> > at
>> >> > compiled pages). Therefore, it's safe to run the code:
>> >> > Request.Form[ddl.uniqueID]
>> >> >
>> >> > Regards
>> >> > --
>> >> > Milosz
>> >> >
>> >> >
>> >> > "Chad Scharf" wrote:
>> >> >
>> >> >> Yes, that would be easier. Sorry, I typically never use
>> >> >> Request.Form
>> >> >> and
>> >> >> forgot about it.
>> >> >>
>> >> >> Is the UniqueID available though in the Page_PreInit event, seeing
>> >> >> as
>> >> >> the
>> >> >> control tree has not yet been built, it would be difficult for the
>> >> >> Page
>> >> >> to
>> >> >> calculate the UniqueID, and typically the Control instance would be
>> >> >> null
>> >> >> as
>> >> >> well no?
>> >> >>
>> >> >> --
>> >> >> Chad Scharf
>> >> >> _______________________________
>> >> >> http://www.chadscharf.com
>> >> >>
>> >> >>
>> >> >> "Milosz Skalecki [MCAD]" wrote:
>> >> >>
>> >> >> > Howdy,
>> >> >> >
>> >> >> > Why using cookie, wouldn't be easier just by using
>> >> >> > string selectedValue = Request.Form[yourDropDown.UniqueID]
>> >> >> > ?
>> >> >> >
>> >> >> >
>> >> >> > --
>> >> >> > Milosz
>> >> >> >
>> >> >> >
>> >> >> > "Chad Scharf" wrote:
>> >> >> >
>> >> >> > > Unfortunately I believe the answer is no. Is there a reason you
>> >> >> > > need
>> >> >> > > this
>> >> >> > > value before the page is initialized?
>> >> >> > >
>> >> >> > > You could potentially inject the value into a cookie using
>> >> >> > > JavaScript
>> >> >> > > using
>> >> >> > > the OnSubmit event of your form, then read that using the
>> >> >> > > HttpContext.Current.Request.Cookies collection to retrieve your
>> >> >> > > value
>> >> >> > > upon
>> >> >> > > post-back. I believe the HttpRequest stack has been created by
>> >> >> > > then
>> >> >> > > and upon
>> >> >> > > calling the OnPreInit method of your page, has built these
>> >> >> > > values
>> >> >> > > from the
>> >> >> > > request headers.
>> >> >> > >
>> >> >> > > --
>> >> >> > > Chad Scharf
>> >> >> > > _______________________________
>> >> >> > > http://www.chadscharf.com
>> >> >> > >
>> >> >> > >
>> >> >> > > "Redhairs" wrote:
>> >> >> > >
>> >> >> > > > Is it possible to get DropDownList.SelectedValue in
>> >> >> > > > Page_PreInit()
>> >> >> > > > event
>> >> >> > > > during the postback?
>> >> >> > > >
>> >> >> > > >
>> >> >> > > >
>> >>
>> >>
>> >>
>>
>>
>>
If you're already in the master page code-behind, why would you reference
"Master.FindControl"? Is the master page nested inside another master page
or something?
Seems like you would want:
string selectedValue =
Request.Form[this.FindControl("placeholdername").FindControl ("ddlID").UniqueID];
Of course, this code assumes that there is a control named "ddlID" inside
"placeholdername" on every single content page that would ever use this
master page. That seems like a pretty unlikely scenario to me.
"Milosz Skalecki [MCAD]"
news:9CB89864-FA79-441B-A3AF-DD636BB84220@microsoft.com...
> Howdy,
>
> In this case (masterpage) you have to manually find the control as it has
> not been referenced yet (but it has been instantiated in the contrnt place
> holder):
>
> string selectedValue =
> Request.Form[Master.FindControl("placeholdername").FindContr ol("ddlID").UniqueID];
>
> It's quite nasty, so my question is why would you need that? The
> difference
> bewteen UniqueID and ClientID is the first is used as "name" attribute for
> input controls and it consists of ID + parents ID (simpifying) separated
> by a
> dollar character, whilst ClientID is used as "id" attribute of all the
> html
> elements that are generated by web controls/html controls with
> runat=server
> separated by underscore char. For more info check this out:
> http://www.shanebauer.com/Weblog/PermaLink,guid,488f7bb3-dac 8-400b-aacf-e94d4da9b533.aspx
> --
> Milosz
>
>
> "Redhairs" wrote:
>
>> Yes, I use use the master page so the DropDownList was placed in the
>> Content
>> control,
>> how to solve this problem?
>> Btw, waht's the difference between ClientID and UniqueID?
>>
>>
>> "Milosz Skalecki [MCAD]"
>> news:BC6247CA-61E5-4908-9C04-C5FF9782BB89@microsoft.com...
>> > Hi Redhairs,
>> >
>> > I checked it and it works fine. Are you by any chance create this
>> > control
>> > dynamically or drop down list is placed inside a tamplated control?
>> > Could
>> > you
>> > please pase some code?
>> >
>> > Regards
>> > --
>> > Milosz
>> >
>> >
>> > "Redhairs" wrote:
>> >
>> >> It doesn't work and return error msg "Object reference not set to an
>> >> instance of an object"
>> >> "Milosz Skalecki [MCAD]"
>> >> news:EF293811-3B1C-4454-B199-FFBD99D95D4E@microsoft.com...
>> >> > Hi Chad,
>> >> >
>> >> > The control tree is already created in PreInit event, as the aspx
>> >> > page
>> >> > compiler puts all the declarations into FrameworkInitialize() method
>> >> > which
>> >> > is
>> >> > called from Page.ProcessRequest (member of the IHttpHandler
>> >> > interface)
>> >> > (have
>> >> > a look at the content of your website's asp.net folder, especially
>> >> > at
>> >> > compiled pages). Therefore, it's safe to run the code:
>> >> > Request.Form[ddl.uniqueID]
>> >> >
>> >> > Regards
>> >> > --
>> >> > Milosz
>> >> >
>> >> >
>> >> > "Chad Scharf" wrote:
>> >> >
>> >> >> Yes, that would be easier. Sorry, I typically never use
>> >> >> Request.Form
>> >> >> and
>> >> >> forgot about it.
>> >> >>
>> >> >> Is the UniqueID available though in the Page_PreInit event, seeing
>> >> >> as
>> >> >> the
>> >> >> control tree has not yet been built, it would be difficult for the
>> >> >> Page
>> >> >> to
>> >> >> calculate the UniqueID, and typically the Control instance would be
>> >> >> null
>> >> >> as
>> >> >> well no?
>> >> >>
>> >> >> --
>> >> >> Chad Scharf
>> >> >> _______________________________
>> >> >> http://www.chadscharf.com
>> >> >>
>> >> >>
>> >> >> "Milosz Skalecki [MCAD]" wrote:
>> >> >>
>> >> >> > Howdy,
>> >> >> >
>> >> >> > Why using cookie, wouldn't be easier just by using
>> >> >> > string selectedValue = Request.Form[yourDropDown.UniqueID]
>> >> >> > ?
>> >> >> >
>> >> >> >
>> >> >> > --
>> >> >> > Milosz
>> >> >> >
>> >> >> >
>> >> >> > "Chad Scharf" wrote:
>> >> >> >
>> >> >> > > Unfortunately I believe the answer is no. Is there a reason you
>> >> >> > > need
>> >> >> > > this
>> >> >> > > value before the page is initialized?
>> >> >> > >
>> >> >> > > You could potentially inject the value into a cookie using
>> >> >> > > JavaScript
>> >> >> > > using
>> >> >> > > the OnSubmit event of your form, then read that using the
>> >> >> > > HttpContext.Current.Request.Cookies collection to retrieve your
>> >> >> > > value
>> >> >> > > upon
>> >> >> > > post-back. I believe the HttpRequest stack has been created by
>> >> >> > > then
>> >> >> > > and upon
>> >> >> > > calling the OnPreInit method of your page, has built these
>> >> >> > > values
>> >> >> > > from the
>> >> >> > > request headers.
>> >> >> > >
>> >> >> > > --
>> >> >> > > Chad Scharf
>> >> >> > > _______________________________
>> >> >> > > http://www.chadscharf.com
>> >> >> > >
>> >> >> > >
>> >> >> > > "Redhairs" wrote:
>> >> >> > >
>> >> >> > > > Is it possible to get DropDownList.SelectedValue in
>> >> >> > > > Page_PreInit()
>> >> >> > > > event
>> >> >> > > > during the postback?
>> >> >> > > >
>> >> >> > > >
>> >> >> > > >
>> >>
>> >>
>> >>
>>
>>
>>
Did you set a break point and look at each object/method result to see which
one was null? I bet it's "Master".
To reiterate Milosz's question, what the heck are you really trying to do?
It seems pretty unlikely that you would ever want the code-behind of a
master page to access controls on a content page.
Also, as long as you keep posting incomplete code/questions you're likely to
keep getting incomplete answers.
"Redhairs"
news:%23tx8QIVWIHA.4076@TK2MSFTNGP03.phx.gbl...
> Thanks for your quick response.
>
> I can find the
> Master.FindControl("placeholdername").FindControl("ddlID").U niqueID in
> Page_PreInit()
> but still get "Object reference not set to an instance of an object" if
> try to access
> Request.Form[Master.FindControl("placeholdername").FindContr ol("ddlID").UniqueID];
>
> But the ddlID.UnigueID is one of the keys of Request.Form collection.
> Can't figure out why.
>
>
>
>
> "Milosz Skalecki [MCAD]"
> news:9CB89864-FA79-441B-A3AF-DD636BB84220@microsoft.com...
>> Howdy,
>>
>> In this case (masterpage) you have to manually find the control as it has
>> not been referenced yet (but it has been instantiated in the contrnt
>> place
>> holder):
>>
>> string selectedValue =
>> Request.Form[Master.FindControl("placeholdername").FindContr ol("ddlID").UniqueID];
>>
>> It's quite nasty, so my question is why would you need that? The
>> difference
>> bewteen UniqueID and ClientID is the first is used as "name" attribute
>> for
>> input controls and it consists of ID + parents ID (simpifying) separated
>> by a
>> dollar character, whilst ClientID is used as "id" attribute of all the
>> html
>> elements that are generated by web controls/html controls with
>> runat=server
>> separated by underscore char. For more info check this out:
>> http://www.shanebauer.com/Weblog/PermaLink,guid,488f7bb3-dac 8-400b-aacf-e94d4da9b533.aspx
>> --
>> Milosz
>>
>>
>> "Redhairs" wrote:
>>
>>> Yes, I use use the master page so the DropDownList was placed in the
>>> Content
>>> control,
>>> how to solve this problem?
>>> Btw, waht's the difference between ClientID and UniqueID?
>>>
>>>
>>> "Milosz Skalecki [MCAD]"
>>> news:BC6247CA-61E5-4908-9C04-C5FF9782BB89@microsoft.com...
>>> > Hi Redhairs,
>>> >
>>> > I checked it and it works fine. Are you by any chance create this
>>> > control
>>> > dynamically or drop down list is placed inside a tamplated control?
>>> > Could
>>> > you
>>> > please pase some code?
>>> >
>>> > Regards
>>> > --
>>> > Milosz
>>> >
>>> >
>>> > "Redhairs" wrote:
>>> >
>>> >> It doesn't work and return error msg "Object reference not set to an
>>> >> instance of an object"
>>> >> "Milosz Skalecki [MCAD]"
>>> >> news:EF293811-3B1C-4454-B199-FFBD99D95D4E@microsoft.com...
>>> >> > Hi Chad,
>>> >> >
>>> >> > The control tree is already created in PreInit event, as the aspx
>>> >> > page
>>> >> > compiler puts all the declarations into FrameworkInitialize()
>>> >> > method
>>> >> > which
>>> >> > is
>>> >> > called from Page.ProcessRequest (member of the IHttpHandler
>>> >> > interface)
>>> >> > (have
>>> >> > a look at the content of your website's asp.net folder, especially
>>> >> > at
>>> >> > compiled pages). Therefore, it's safe to run the code:
>>> >> > Request.Form[ddl.uniqueID]
>>> >> >
>>> >> > Regards
>>> >> > --
>>> >> > Milosz
>>> >> >
>>> >> >
>>> >> > "Chad Scharf" wrote:
>>> >> >
>>> >> >> Yes, that would be easier. Sorry, I typically never use
>>> >> >> Request.Form
>>> >> >> and
>>> >> >> forgot about it.
>>> >> >>
>>> >> >> Is the UniqueID available though in the Page_PreInit event, seeing
>>> >> >> as
>>> >> >> the
>>> >> >> control tree has not yet been built, it would be difficult for the
>>> >> >> Page
>>> >> >> to
>>> >> >> calculate the UniqueID, and typically the Control instance would
>>> >> >> be
>>> >> >> null
>>> >> >> as
>>> >> >> well no?
>>> >> >>
>>> >> >> --
>>> >> >> Chad Scharf
>>> >> >> _______________________________
>>> >> >> http://www.chadscharf.com
>>> >> >>
>>> >> >>
>>> >> >> "Milosz Skalecki [MCAD]" wrote:
>>> >> >>
>>> >> >> > Howdy,
>>> >> >> >
>>> >> >> > Why using cookie, wouldn't be easier just by using
>>> >> >> > string selectedValue = Request.Form[yourDropDown.UniqueID]
>>> >> >> > ?
>>> >> >> >
>>> >> >> >
>>> >> >> > --
>>> >> >> > Milosz
>>> >> >> >
>>> >> >> >
>>> >> >> > "Chad Scharf" wrote:
>>> >> >> >
>>> >> >> > > Unfortunately I believe the answer is no. Is there a reason
>>> >> >> > > you
>>> >> >> > > need
>>> >> >> > > this
>>> >> >> > > value before the page is initialized?
>>> >> >> > >
>>> >> >> > > You could potentially inject the value into a cookie using
>>> >> >> > > JavaScript
>>> >> >> > > using
>>> >> >> > > the OnSubmit event of your form, then read that using the
>>> >> >> > > HttpContext.Current.Request.Cookies collection to retrieve
>>> >> >> > > your
>>> >> >> > > value
>>> >> >> > > upon
>>> >> >> > > post-back. I believe the HttpRequest stack has been created by
>>> >> >> > > then
>>> >> >> > > and upon
>>> >> >> > > calling the OnPreInit method of your page, has built these
>>> >> >> > > values
>>> >> >> > > from the
>>> >> >> > > request headers.
>>> >> >> > >
>>> >> >> > > --
>>> >> >> > > Chad Scharf
>>> >> >> > > _______________________________
>>> >> >> > > http://www.chadscharf.com
>>> >> >> > >
>>> >> >> > >
>>> >> >> > > "Redhairs" wrote:
>>> >> >> > >
>>> >> >> > > > Is it possible to get DropDownList.SelectedValue in
>>> >> >> > > > Page_PreInit()
>>> >> >> > > > event
>>> >> >> > > > during the postback?
>>> >> >> > > >
>>> >> >> > > >
>>> >> >> > > >
>>> >>
>>> >>
>>> >>
>>>
>>>
>>>
>
>
The dropdownlist control is in content page not the master page.
What I want to do is to have a master page drop-down list, and its
OnSelectionIndexChange event
will postback and apply different master page in Page_PreInit() event
"Scott Roberts"
message news:eYaddSVWIHA.2000@TK2MSFTNGP05.phx.gbl...
> If you're already in the master page code-behind, why would you reference
> "Master.FindControl"? Is the master page nested inside another master page
> or something?
>
> Seems like you would want:
>
> string selectedValue =
> Request.Form[this.FindControl("placeholdername").FindControl ("ddlID").UniqueID];
>
> Of course, this code assumes that there is a control named "ddlID" inside
> "placeholdername" on every single content page that would ever use this
> master page. That seems like a pretty unlikely scenario to me.
>
>
> "Milosz Skalecki [MCAD]"
> news:9CB89864-FA79-441B-A3AF-DD636BB84220@microsoft.com...
>> Howdy,
>>
>> In this case (masterpage) you have to manually find the control as it has
>> not been referenced yet (but it has been instantiated in the contrnt
>> place
>> holder):
>>
>> string selectedValue =
>> Request.Form[Master.FindControl("placeholdername").FindContr ol("ddlID").UniqueID];
>>
>> It's quite nasty, so my question is why would you need that? The
>> difference
>> bewteen UniqueID and ClientID is the first is used as "name" attribute
>> for
>> input controls and it consists of ID + parents ID (simpifying) separated
>> by a
>> dollar character, whilst ClientID is used as "id" attribute of all the
>> html
>> elements that are generated by web controls/html controls with
>> runat=server
>> separated by underscore char. For more info check this out:
>> http://www.shanebauer.com/Weblog/PermaLink,guid,488f7bb3-dac 8-400b-aacf-e94d4da9b533.aspx
>> --
>> Milosz
>>
>>
>> "Redhairs" wrote:
>>
>>> Yes, I use use the master page so the DropDownList was placed in the
>>> Content
>>> control,
>>> how to solve this problem?
>>> Btw, waht's the difference between ClientID and UniqueID?
>>>
>>>
>>> "Milosz Skalecki [MCAD]"
>>> news:BC6247CA-61E5-4908-9C04-C5FF9782BB89@microsoft.com...
>>> > Hi Redhairs,
>>> >
>>> > I checked it and it works fine. Are you by any chance create this
>>> > control
>>> > dynamically or drop down list is placed inside a tamplated control?
>>> > Could
>>> > you
>>> > please pase some code?
>>> >
>>> > Regards
>>> > --
>>> > Milosz
>>> >
>>> >
>>> > "Redhairs" wrote:
>>> >
>>> >> It doesn't work and return error msg "Object reference not set to an
>>> >> instance of an object"
>>> >> "Milosz Skalecki [MCAD]"
>>> >> news:EF293811-3B1C-4454-B199-FFBD99D95D4E@microsoft.com...
>>> >> > Hi Chad,
>>> >> >
>>> >> > The control tree is already created in PreInit event, as the aspx
>>> >> > page
>>> >> > compiler puts all the declarations into FrameworkInitialize()
>>> >> > method
>>> >> > which
>>> >> > is
>>> >> > called from Page.ProcessRequest (member of the IHttpHandler
>>> >> > interface)
>>> >> > (have
>>> >> > a look at the content of your website's asp.net folder, especially
>>> >> > at
>>> >> > compiled pages). Therefore, it's safe to run the code:
>>> >> > Request.Form[ddl.uniqueID]
>>> >> >
>>> >> > Regards
>>> >> > --
>>> >> > Milosz
>>> >> >
>>> >> >
>>> >> > "Chad Scharf" wrote:
>>> >> >
>>> >> >> Yes, that would be easier. Sorry, I typically never use
>>> >> >> Request.Form
>>> >> >> and
>>> >> >> forgot about it.
>>> >> >>
>>> >> >> Is the UniqueID available though in the Page_PreInit event, seeing
>>> >> >> as
>>> >> >> the
>>> >> >> control tree has not yet been built, it would be difficult for the
>>> >> >> Page
>>> >> >> to
>>> >> >> calculate the UniqueID, and typically the Control instance would
>>> >> >> be
>>> >> >> null
>>> >> >> as
>>> >> >> well no?
>>> >> >>
>>> >> >> --
>>> >> >> Chad Scharf
>>> >> >> _______________________________
>>> >> >> http://www.chadscharf.com
>>> >> >>
>>> >> >>
>>> >> >> "Milosz Skalecki [MCAD]" wrote:
>>> >> >>
>>> >> >> > Howdy,
>>> >> >> >
>>> >> >> > Why using cookie, wouldn't be easier just by using
>>> >> >> > string selectedValue = Request.Form[yourDropDown.UniqueID]
>>> >> >> > ?
>>> >> >> >
>>> >> >> >
>>> >> >> > --
>>> >> >> > Milosz
>>> >> >> >
>>> >> >> >
>>> >> >> > "Chad Scharf" wrote:
>>> >> >> >
>>> >> >> > > Unfortunately I believe the answer is no. Is there a reason
>>> >> >> > > you
>>> >> >> > > need
>>> >> >> > > this
>>> >> >> > > value before the page is initialized?
>>> >> >> > >
>>> >> >> > > You could potentially inject the value into a cookie using
>>> >> >> > > JavaScript
>>> >> >> > > using
>>> >> >> > > the OnSubmit event of your form, then read that using the
>>> >> >> > > HttpContext.Current.Request.Cookies collection to retrieve
>>> >> >> > > your
>>> >> >> > > value
>>> >> >> > > upon
>>> >> >> > > post-back. I believe the HttpRequest stack has been created by
>>> >> >> > > then
>>> >> >> > > and upon
>>> >> >> > > calling the OnPreInit method of your page, has built these
>>> >> >> > > values
>>> >> >> > > from the
>>> >> >> > > request headers.
>>> >> >> > >
>>> >> >> > > --
>>> >> >> > > Chad Scharf
>>> >> >> > > _______________________________
>>> >> >> > > http://www.chadscharf.com
>>> >> >> > >
>>> >> >> > >
>>> >> >> > > "Redhairs" wrote:
>>> >> >> > >
>>> >> >> > > > Is it possible to get DropDownList.SelectedValue in
>>> >> >> > > > Page_PreInit()
>>> >> >> > > > event
>>> >> >> > > > during the postback?
>>> >> >> > > >
>>> >> >> > > >
>>> >> >> > > >
>>> >>
>>> >>
>>> >>
>>>
>>>
>>>
>
I find if I change the drop-down list first time, the page will postback and
get the
Request.Form[_theDDL.UnigueID] correctly in Page_PreInit(). but the
drop-downlist
won't change and onSelectionIndexChanged won't be triggered.
Then I change the drow-down list again, this time CAN NOT find the
Request.Form[_theDDL.UnigueID] correctly in Page_PreInit().
butbut the drop-downlist change and onSelectionIndexChanged is raised.
Do I miss any thing here?
"Redhairs"
news:O$C0qOVWIHA.4740@TK2MSFTNGP02.phx.gbl...
> The source codes are as below, the page is inherited from one base class
>
> Test.aspx:
>
>
>
>
>
> Test.aspx.cs
> void Page_PreInit(object sender, EventArg e)
> {
>
> DropDownList _theDDL = (DropDownList)
> Master.FindControl("TheHolder").FindControl("langSelection") ;
> if (_theDDL != null)
> Response.Write(Request.Form[_theDDL.UnigueID]); // null Object
> reference err here
> }
>
>
>
>
>
>
>
> "Milosz Skalecki [MCAD]"
> news:9CB89864-FA79-441B-A3AF-DD636BB84220@microsoft.com...
>> Howdy,
>>
>> In this case (masterpage) you have to manually find the control as it has
>> not been referenced yet (but it has been instantiated in the contrnt
>> place
>> holder):
>>
>> string selectedValue =
>> Request.Form[Master.FindControl("placeholdername").FindContr ol("ddlID").UniqueID];
>>
>> It's quite nasty, so my question is why would you need that? The
>> difference
>> bewteen UniqueID and ClientID is the first is used as "name" attribute
>> for
>> input controls and it consists of ID + parents ID (simpifying) separated
>> by a
>> dollar character, whilst ClientID is used as "id" attribute of all the
>> html
>> elements that are generated by web controls/html controls with
>> runat=server
>> separated by underscore char. For more info check this out:
>> http://www.shanebauer.com/Weblog/PermaLink,guid,488f7bb3-dac 8-400b-aacf-e94d4da9b533.aspx
>> --
>> Milosz
>>
>>
>> "Redhairs" wrote:
>>
>>> Yes, I use use the master page so the DropDownList was placed in the
>>> Content
>>> control,
>>> how to solve this problem?
>>> Btw, waht's the difference between ClientID and UniqueID?
>>>
>>>
>>> "Milosz Skalecki [MCAD]"
>>> news:BC6247CA-61E5-4908-9C04-C5FF9782BB89@microsoft.com...
>>> > Hi Redhairs,
>>> >
>>> > I checked it and it works fine. Are you by any chance create this
>>> > control
>>> > dynamically or drop down list is placed inside a tamplated control?
>>> > Could
>>> > you
>>> > please pase some code?
>>> >
>>> > Regards
>>> > --
>>> > Milosz
>>> >
>>> >
>>> > "Redhairs" wrote:
>>> >
>>> >> It doesn't work and return error msg "Object reference not set to an
>>> >> instance of an object"
>>> >> "Milosz Skalecki [MCAD]"
>>> >> news:EF293811-3B1C-4454-B199-FFBD99D95D4E@microsoft.com...
>>> >> > Hi Chad,
>>> >> >
>>> >> > The control tree is already created in PreInit event, as the aspx
>>> >> > page
>>> >> > compiler puts all the declarations into FrameworkInitialize()
>>> >> > method
>>> >> > which
>>> >> > is
>>> >> > called from Page.ProcessRequest (member of the IHttpHandler
>>> >> > interface)
>>> >> > (have
>>> >> > a look at the content of your website's asp.net folder, especially
>>> >> > at
>>> >> > compiled pages). Therefore, it's safe to run the code:
>>> >> > Request.Form[ddl.uniqueID]
>>> >> >
>>> >> > Regards
>>> >> > --
>>> >> > Milosz
>>> >> >
>>> >> >
>>> >> > "Chad Scharf" wrote:
>>> >> >
>>> >> >> Yes, that would be easier. Sorry, I typically never use
>>> >> >> Request.Form
>>> >> >> and
>>> >> >> forgot about it.
>>> >> >>
>>> >> >> Is the UniqueID available though in the Page_PreInit event, seeing
>>> >> >> as
>>> >> >> the
>>> >> >> control tree has not yet been built, it would be difficult for the
>>> >> >> Page
>>> >> >> to
>>> >> >> calculate the UniqueID, and typically the Control instance would
>>> >> >> be
>>> >> >> null
>>> >> >> as
>>> >> >> well no?
>>> >> >>
>>> >> >> --
>>> >> >> Chad Scharf
>>> >> >> _______________________________
>>> >> >> http://www.chadscharf.com
>>> >> >>
>>> >> >>
>>> >> >> "Milosz Skalecki [MCAD]" wrote:
>>> >> >>
>>> >> >> > Howdy,
>>> >> >> >
>>> >> >> > Why using cookie, wouldn't be easier just by using
>>> >> >> > string selectedValue = Request.Form[yourDropDown.UniqueID]
>>> >> >> > ?
>>> >> >> >
>>> >> >> >
>>> >> >> > --
>>> >> >> > Milosz
>>> >> >> >
>>> >> >> >
>>> >> >> > "Chad Scharf" wrote:
>>> >> >> >
>>> >> >> > > Unfortunately I believe the answer is no. Is there a reason
>>> >> >> > > you
>>> >> >> > > need
>>> >> >> > > this
>>> >> >> > > value before the page is initialized?
>>> >> >> > >
>>> >> >> > > You could potentially inject the value into a cookie using
>>> >> >> > > JavaScript
>>> >> >> > > using
>>> >> >> > > the OnSubmit event of your form, then read that using the
>>> >> >> > > HttpContext.Current.Request.Cookies collection to retrieve
>>> >> >> > > your
>>> >> >> > > value
>>> >> >> > > upon
>>> >> >> > > post-back. I believe the HttpRequest stack has been created by
>>> >> >> > > then
>>> >> >> > > and upon
>>> >> >> > > calling the OnPreInit method of your page, has built these
>>> >> >> > > values
>>> >> >> > > from the
>>> >> >> > > request headers.
>>> >> >> > >
>>> >> >> > > --
>>> >> >> > > Chad Scharf
>>> >> >> > > _______________________________
>>> >> >> > > http://www.chadscharf.com
>>> >> >> > >
>>> >> >> > >
>>> >> >> > > "Redhairs" wrote:
>>> >> >> > >
>>> >> >> > > > Is it possible to get DropDownList.SelectedValue in
>>> >> >> > > > Page_PreInit()
>>> >> >> > > > event
>>> >> >> > > > during the postback?
>>> >> >> > > >
>>> >> >> > > >
>>> >> >> > > >
>>> >>
>>> >>
>>> >>
>>>
>>>
>>>
>
>
Hi Red,
I don't know what is happening in your code but everything is hunky-dory in
mine. Could you please paste entire code from both aspx page and code beside.
Regards
--
Milosz
"Redhairs" wrote:
> I find if I change the drop-down list first time, the page will postback and
> get the
> Request.Form[_theDDL.UnigueID] correctly in Page_PreInit(). but the
> drop-downlist
> won't change and onSelectionIndexChanged won't be triggered.
>
> Then I change the drow-down list again, this time CAN NOT find the
> Request.Form[_theDDL.UnigueID] correctly in Page_PreInit().
> butbut the drop-downlist change and onSelectionIndexChanged is raised.
>
> Do I miss any thing here?
>
>
>
> "Redhairs"
> news:O$C0qOVWIHA.4740@TK2MSFTNGP02.phx.gbl...
> > The source codes are as below, the page is inherited from one base class
> >
> > Test.aspx:
> >
> >
> >
> >
> >
> > Test.aspx.cs
> > void Page_PreInit(object sender, EventArg e)
> > {
> >
> > DropDownList _theDDL = (DropDownList)
> > Master.FindControl("TheHolder").FindControl("langSelection") ;
> > if (_theDDL != null)
> > Response.Write(Request.Form[_theDDL.UnigueID]); // null Object
> > reference err here
> > }
> >
> >
> >
> >
> >
> >
> >
> > "Milosz Skalecki [MCAD]"
> > news:9CB89864-FA79-441B-A3AF-DD636BB84220@microsoft.com...
> >> Howdy,
> >>
> >> In this case (masterpage) you have to manually find the control as it has
> >> not been referenced yet (but it has been instantiated in the contrnt
> >> place
> >> holder):
> >>
> >> string selectedValue =
> >> Request.Form[Master.FindControl("placeholdername").FindContr ol("ddlID").UniqueID];
> >>
> >> It's quite nasty, so my question is why would you need that? The
> >> difference
> >> bewteen UniqueID and ClientID is the first is used as "name" attribute
> >> for
> >> input controls and it consists of ID + parents ID (simpifying) separated
> >> by a
> >> dollar character, whilst ClientID is used as "id" attribute of all the
> >> html
> >> elements that are generated by web controls/html controls with
> >> runat=server
> >> separated by underscore char. For more info check this out:
> >> http://www.shanebauer.com/Weblog/PermaLink,guid,488f7bb3-dac 8-400b-aacf-e94d4da9b533.aspx
> >> --
> >> Milosz
> >>
> >>
> >> "Redhairs" wrote:
> >>
> >>> Yes, I use use the master page so the DropDownList was placed in the
> >>> Content
> >>> control,
> >>> how to solve this problem?
> >>> Btw, waht's the difference between ClientID and UniqueID?
> >>>
> >>>
> >>> "Milosz Skalecki [MCAD]"
> >>> news:BC6247CA-61E5-4908-9C04-C5FF9782BB89@microsoft.com...
> >>> > Hi Redhairs,
> >>> >
> >>> > I checked it and it works fine. Are you by any chance create this
> >>> > control
> >>> > dynamically or drop down list is placed inside a tamplated control?
> >>> > Could
> >>> > you
> >>> > please pase some code?
> >>> >
> >>> > Regards
> >>> > --
> >>> > Milosz
> >>> >
> >>> >
> >>> > "Redhairs" wrote:
> >>> >
> >>> >> It doesn't work and return error msg "Object reference not set to an
> >>> >> instance of an object"
> >>> >> "Milosz Skalecki [MCAD]"
> >>> >> news:EF293811-3B1C-4454-B199-FFBD99D95D4E@microsoft.com...
> >>> >> > Hi Chad,
> >>> >> >
> >>> >> > The control tree is already created in PreInit event, as the aspx
> >>> >> > page
> >>> >> > compiler puts all the declarations into FrameworkInitialize()
> >>> >> > method
> >>> >> > which
> >>> >> > is
> >>> >> > called from Page.ProcessRequest (member of the IHttpHandler
> >>> >> > interface)
> >>> >> > (have
> >>> >> > a look at the content of your website's asp.net folder, especially
> >>> >> > at
> >>> >> > compiled pages). Therefore, it's safe to run the code:
> >>> >> > Request.Form[ddl.uniqueID]
> >>> >> >
> >>> >> > Regards
> >>> >> > --
> >>> >> > Milosz
> >>> >> >
> >>> >> >
> >>> >> > "Chad Scharf" wrote:
> >>> >> >
> >>> >> >> Yes, that would be easier. Sorry, I typically never use
> >>> >> >> Request.Form
> >>> >> >> and
> >>> >> >> forgot about it.
> >>> >> >>
> >>> >> >> Is the UniqueID available though in the Page_PreInit event, seeing
> >>> >> >> as
> >>> >> >> the
> >>> >> >> control tree has not yet been built, it would be difficult for the
> >>> >> >> Page
> >>> >> >> to
> >>> >> >> calculate the UniqueID, and typically the Control instance would
> >>> >> >> be
> >>> >> >> null
> >>> >> >> as
> >>> >> >> well no?
> >>> >> >>
> >>> >> >> --
> >>> >> >> Chad Scharf
> >>> >> >> _______________________________
> >>> >> >> http://www.chadscharf.com
> >>> >> >>
> >>> >> >>
> >>> >> >> "Milosz Skalecki [MCAD]" wrote:
> >>> >> >>
> >>> >> >> > Howdy,
> >>> >> >> >
> >>> >> >> > Why using cookie, wouldn't be easier just by using
> >>> >> >> > string selectedValue = Request.Form[yourDropDown.UniqueID]
> >>> >> >> > ?
> >>> >> >> >
> >>> >> >> >
> >>> >> >> > --
> >>> >> >> > Milosz
> >>> >> >> >
> >>> >> >> >
> >>> >> >> > "Chad Scharf" wrote:
> >>> >> >> >
> >>> >> >> > > Unfortunately I believe the answer is no. Is there a reason
> >>> >> >> > > you
> >>> >> >> > > need
> >>> >> >> > > this
> >>> >> >> > > value before the page is initialized?
> >>> >> >> > >
> >>> >> >> > > You could potentially inject the value into a cookie using
> >>> >> >> > > JavaScript
> >>> >> >> > > using
> >>> >> >> > > the OnSubmit event of your form, then read that using the
> >>> >> >> > > HttpContext.Current.Request.Cookies collection to retrieve
> >>> >> >> > > your
> >>> >> >> > > value
> >>> >> >> > > upon
> >>> >> >> > > post-back. I believe the HttpRequest stack has been created by
> >>> >> >> > > then
> >>> >> >> > > and upon
> >>> >> >> > > calling the OnPreInit method of your page, has built these
> >>> >> >> > > values
> >>> >> >> > > from the
> >>> >> >> > > request headers.
> >>> >> >> > >
> >>> >> >> > > --
> >>> >> >> > > Chad Scharf
> >>> >> >> > > _______________________________
> >>> >> >> > > http://www.chadscharf.com
> >>> >> >> > >
> >>> >> >> > >
> >>> >> >> > > "Redhairs" wrote:
> >>> >> >> > >
> >>> >> >> > > > Is it possible to get DropDownList.SelectedValue in
> >>> >> >> > > > Page_PreInit()
> >>> >> >> > > > event
> >>> >> >> > > > during the postback?
> >>> >> >> > > >
> >>> >> >> > > >
> >>> >> >> > > >
> >>> >>
> >>> >>
> >>> >>
> >>>
> >>>
> >>>
> >
> >
>
>
>
I finally found a clue but not sure if it's correct or not.
My goal is to dynamically apply master page in Page_PreInit() with the
selected value of drop-down list.
(the drop-down-list control is placed in the Content control), so during the
postback, I need to read the
selected value of drop-down list in Page_PreInit() event then set the
Page.MasterPageFile property.
Since the dropdownlist is not created yet in Page_PreInit() and I need to
use Master.FindControl......
way to retrieve the UniqueID and value from Request.Form collection. But at
this time I haven't set the
master page, so the Master is a null object and I can't find the
dropdownlist.UniqueID.
Any workaround? I can only append the selected value as the querystring but
no postback any more?
"Milosz Skalecki [MCAD]"
news:9C78BD50-AE15-40FF-A379-34E7DA8C43AE@microsoft.com...
> Hi Red,
>
> I don't know what is happening in your code but everything is hunky-dory
> in
> mine. Could you please paste entire code from both aspx page and code
> beside.
>
> Regards
> --
> Milosz
>
>
> "Redhairs" wrote:
>
>> I find if I change the drop-down list first time, the page will postback
>> and
>> get the
>> Request.Form[_theDDL.UnigueID] correctly in Page_PreInit(). but the
>> drop-downlist
>> won't change and onSelectionIndexChanged won't be triggered.
>>
>> Then I change the drow-down list again, this time CAN NOT find the
>> Request.Form[_theDDL.UnigueID] correctly in Page_PreInit().
>> butbut the drop-downlist change and onSelectionIndexChanged is raised.
>>
>> Do I miss any thing here?
>>
>>
>>
>> "Redhairs"
>> news:O$C0qOVWIHA.4740@TK2MSFTNGP02.phx.gbl...
>> > The source codes are as below, the page is inherited from one base
>> > class
>> >
>> > Test.aspx:
>> >
>> >
>> > OnSelectionIndexChanged="......"/>
>> >
>> >
>> >
>> > Test.aspx.cs
>> > void Page_PreInit(object sender, EventArg e)
>> > {
>> >
>> > DropDownList _theDDL = (DropDownList)
>> > Master.FindControl("TheHolder").FindControl("langSelection") ;
>> > if (_theDDL != null)
>> > Response.Write(Request.Form[_theDDL.UnigueID]); // null Object
>> > reference err here
>> > }
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > "Milosz Skalecki [MCAD]"
>> > news:9CB89864-FA79-441B-A3AF-DD636BB84220@microsoft.com...
>> >> Howdy,
>> >>
>> >> In this case (masterpage) you have to manually find the control as it
>> >> has
>> >> not been referenced yet (but it has been instantiated in the contrnt
>> >> place
>> >> holder):
>> >>
>> >> string selectedValue =
>> >> Request.Form[Master.FindControl("placeholdername").FindContr ol("ddlID").UniqueID];
>> >>
>> >> It's quite nasty, so my question is why would you need that? The
>> >> difference
>> >> bewteen UniqueID and ClientID is the first is used as "name" attribute
>> >> for
>> >> input controls and it consists of ID + parents ID (simpifying)
>> >> separated
>> >> by a
>> >> dollar character, whilst ClientID is used as "id" attribute of all the
>> >> html
>> >> elements that are generated by web controls/html controls with
>> >> runat=server
>> >> separated by underscore char. For more info check this out:
>> >> http://www.shanebauer.com/Weblog/PermaLink,guid,488f7bb3-dac 8-400b-aacf-e94d4da9b533.aspx
>> >> --
>> >> Milosz
>> >>
>> >>
>> >> "Redhairs" wrote:
>> >>
>> >>> Yes, I use use the master page so the DropDownList was placed in the
>> >>> Content
>> >>> control,
>> >>> how to solve this problem?
>> >>> Btw, waht's the difference between ClientID and UniqueID?
>> >>>
>> >>>
>> >>> "Milosz Skalecki [MCAD]"
>> >>> news:BC6247CA-61E5-4908-9C04-C5FF9782BB89@microsoft.com...
>> >>> > Hi Redhairs,
>> >>> >
>> >>> > I checked it and it works fine. Are you by any chance create this
>> >>> > control
>> >>> > dynamically or drop down list is placed inside a tamplated control?
>> >>> > Could
>> >>> > you
>> >>> > please pase some code?
>> >>> >
>> >>> > Regards
>> >>> > --
>> >>> > Milosz
>> >>> >
>> >>> >
>> >>> > "Redhairs" wrote:
>> >>> >
>> >>> >> It doesn't work and return error msg "Object reference not set to
>> >>> >> an
>> >>> >> instance of an object"
>> >>> >> "Milosz Skalecki [MCAD]"
>> >>> >> message
>> >>> >> news:EF293811-3B1C-4454-B199-FFBD99D95D4E@microsoft.com...
>> >>> >> > Hi Chad,
>> >>> >> >
>> >>> >> > The control tree is already created in PreInit event, as the
>> >>> >> > aspx
>> >>> >> > page
>> >>> >> > compiler puts all the declarations into FrameworkInitialize()
>> >>> >> > method
>> >>> >> > which
>> >>> >> > is
>> >>> >> > called from Page.ProcessRequest (member of the IHttpHandler
>> >>> >> > interface)
>> >>> >> > (have
>> >>> >> > a look at the content of your website's asp.net folder,
>> >>> >> > especially
>> >>> >> > at
>> >>> >> > compiled pages). Therefore, it's safe to run the code:
>> >>> >> > Request.Form[ddl.uniqueID]
>> >>> >> >
>> >>> >> > Regards
>> >>> >> > --
>> >>> >> > Milosz
>> >>> >> >
>> >>> >> >
>> >>> >> > "Chad Scharf" wrote:
>> >>> >> >
>> >>> >> >> Yes, that would be easier. Sorry, I typically never use
>> >>> >> >> Request.Form
>> >>> >> >> and
>> >>> >> >> forgot about it.
>> >>> >> >>
>> >>> >> >> Is the UniqueID available though in the Page_PreInit event,
>> >>> >> >> seeing
>> >>> >> >> as
>> >>> >> >> the
>> >>> >> >> control tree has not yet been built, it would be difficult for
>> >>> >> >> the
>> >>> >> >> Page
>> >>> >> >> to
>> >>> >> >> calculate the UniqueID, and typically the Control instance
>> >>> >> >> would
>> >>> >> >> be
>> >>> >> >> null
>> >>> >> >> as
>> >>> >> >> well no?
>> >>> >> >>
>> >>> >> >> --
>> >>> >> >> Chad Scharf
>> >>> >> >> _______________________________
>> >>> >> >> http://www.chadscharf.com
>> >>> >> >>
>> >>> >> >>
>> >>> >> >> "Milosz Skalecki [MCAD]" wrote:
>> >>> >> >>
>> >>> >> >> > Howdy,
>> >>> >> >> >
>> >>> >> >> > Why using cookie, wouldn't be easier just by using
>> >>> >> >> > string selectedValue = Request.Form[yourDropDown.UniqueID]
>> >>> >> >> > ?
>> >>> >> >> >
>> >>> >> >> >
>> >>> >> >> > --
>> >>> >> >> > Milosz
>> >>> >> >> >
>> >>> >> >> >
>> >>> >> >> > "Chad Scharf" wrote:
>> >>> >> >> >
>> >>> >> >> > > Unfortunately I believe the answer is no. Is there a reason
>> >>> >> >> > > you
>> >>> >> >> > > need
>> >>> >> >> > > this
>> >>> >> >> > > value before the page is initialized?
>> >>> >> >> > >
>> >>> >> >> > > You could potentially inject the value into a cookie using
>> >>> >> >> > > JavaScript
>> >>> >> >> > > using
>> >>> >> >> > > the OnSubmit event of your form, then read that using the
>> >>> >> >> > > HttpContext.Current.Request.Cookies collection to retrieve
>> >>> >> >> > > your
>> >>> >> >> > > value
>> >>> >> >> > > upon
>> >>> >> >> > > post-back. I believe the HttpRequest stack has been created
>> >>> >> >> > > by
>> >>> >> >> > > then
>> >>> >> >> > > and upon
>> >>> >> >> > > calling the OnPreInit method of your page, has built these
>> >>> >> >> > > values
>> >>> >> >> > > from the
>> >>> >> >> > > request headers.
>> >>> >> >> > >
>> >>> >> >> > > --
>> >>> >> >> > > Chad Scharf
>> >>> >> >> > > _______________________________
>> >>> >> >> > > http://www.chadscharf.com
>> >>> >> >> > >
>> >>> >> >> > >
>> >>> >> >> > > "Redhairs" wrote:
>> >>> >> >> > >
>> >>> >> >> > > > Is it possible to get DropDownList.SelectedValue in
>> >>> >> >> > > > Page_PreInit()
>> >>> >> >> > > > event
>> >>> >> >> > > > during the postback?
>> >>> >> >> > > >
>> >>> >> >> > > >
>> >>> >> >> > > >
>> >>> >>
>> >>> >>
>> >>> >>
>> >>>
>> >>>
>> >>>
>> >
>> >
>>
>>
>>
Actually, the DDL.UniqueID="Value" do exist in the Request.Form collection
but
can't retrieve it via Request.Form[DDL.UniqueID], is it because server will
validate
the viewstate?
"Redhairs"
news:uCLL%23BjWIHA.5208@TK2MSFTNGP04.phx.gbl...
>I finally found a clue but not sure if it's correct or not.
>
> My goal is to dynamically apply master page in Page_PreInit() with the
> selected value of drop-down list.
> (the drop-down-list control is placed in the Content control), so during
> the postback, I need to read the
> selected value of drop-down list in Page_PreInit() event then set the
> Page.MasterPageFile property.
>
> Since the dropdownlist is not created yet in Page_PreInit() and I need to
> use Master.FindControl......
> way to retrieve the UniqueID and value from Request.Form collection. But
> at this time I haven't set the
> master page, so the Master is a null object and I can't find the
> dropdownlist.UniqueID.
>
> Any workaround? I can only append the selected value as the querystring
> but no postback any more?
>
>
>
>
> "Milosz Skalecki [MCAD]"
> news:9C78BD50-AE15-40FF-A379-34E7DA8C43AE@microsoft.com...
>> Hi Red,
>>
>> I don't know what is happening in your code but everything is hunky-dory
>> in
>> mine. Could you please paste entire code from both aspx page and code
>> beside.
>>
>> Regards
>> --
>> Milosz
>>
>>
>> "Redhairs" wrote:
>>
>>> I find if I change the drop-down list first time, the page will postback
>>> and
>>> get the
>>> Request.Form[_theDDL.UnigueID] correctly in Page_PreInit(). but the
>>> drop-downlist
>>> won't change and onSelectionIndexChanged won't be triggered.
>>>
>>> Then I change the drow-down list again, this time CAN NOT find the
>>> Request.Form[_theDDL.UnigueID] correctly in Page_PreInit().
>>> butbut the drop-downlist change and onSelectionIndexChanged is raised.
>>>
>>> Do I miss any thing here?
>>>
>>>
>>>
>>> "Redhairs"
>>> news:O$C0qOVWIHA.4740@TK2MSFTNGP02.phx.gbl...
>>> > The source codes are as below, the page is inherited from one base
>>> > class
>>> >
>>> > Test.aspx:
>>> >
>>> >
>>> > OnSelectionIndexChanged="......"/>
>>> >
>>> >
>>> >
>>> > Test.aspx.cs
>>> > void Page_PreInit(object sender, EventArg e)
>>> > {
>>> >
>>> > DropDownList _theDDL = (DropDownList)
>>> > Master.FindControl("TheHolder").FindControl("langSelection") ;
>>> > if (_theDDL != null)
>>> > Response.Write(Request.Form[_theDDL.UnigueID]); // null Object
>>> > reference err here
>>> > }
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> > "Milosz Skalecki [MCAD]"
>>> > news:9CB89864-FA79-441B-A3AF-DD636BB84220@microsoft.com...
>>> >> Howdy,
>>> >>
>>> >> In this case (masterpage) you have to manually find the control as it
>>> >> has
>>> >> not been referenced yet (but it has been instantiated in the contrnt
>>> >> place
>>> >> holder):
>>> >>
>>> >> string selectedValue =
>>> >> Request.Form[Master.FindControl("placeholdername").FindContr ol("ddlID").UniqueID];
>>> >>
>>> >> It's quite nasty, so my question is why would you need that? The
>>> >> difference
>>> >> bewteen UniqueID and ClientID is the first is used as "name"
>>> >> attribute
>>> >> for
>>> >> input controls and it consists of ID + parents ID (simpifying)
>>> >> separated
>>> >> by a
>>> >> dollar character, whilst ClientID is used as "id" attribute of all
>>> >> the
>>> >> html
>>> >> elements that are generated by web controls/html controls with
>>> >> runat=server
>>> >> separated by underscore char. For more info check this out:
>>> >> http://www.shanebauer.com/Weblog/PermaLink,guid,488f7bb3-dac 8-400b-aacf-e94d4da9b533.aspx
>>> >> --
>>> >> Milosz
>>> >>
>>> >>
>>> >> "Redhairs" wrote:
>>> >>
>>> >>> Yes, I use use the master page so the DropDownList was placed in the
>>> >>> Content
>>> >>> control,
>>> >>> how to solve this problem?
>>> >>> Btw, waht's the difference between ClientID and UniqueID?
>>> >>>
>>> >>>
>>> >>> "Milosz Skalecki [MCAD]"
>>> >>> message
>>> >>> news:BC6247CA-61E5-4908-9C04-C5FF9782BB89@microsoft.com...
>>> >>> > Hi Redhairs,
>>> >>> >
>>> >>> > I checked it and it works fine. Are you by any chance create this
>>> >>> > control
>>> >>> > dynamically or drop down list is placed inside a tamplated
>>> >>> > control?
>>> >>> > Could
>>> >>> > you
>>> >>> > please pase some code?
>>> >>> >
>>> >>> > Regards
>>> >>> > --
>>> >>> > Milosz
>>> >>> >
>>> >>> >
>>> >>> > "Redhairs" wrote:
>>> >>> >
>>> >>> >> It doesn't work and return error msg "Object reference not set to
>>> >>> >> an
>>> >>> >> instance of an object"
>>> >>> >> "Milosz Skalecki [MCAD]"
>>> >>> >> message
>>> >>> >> news:EF293811-3B1C-4454-B199-FFBD99D95D4E@microsoft.com...
>>> >>> >> > Hi Chad,
>>> >>> >> >
>>> >>> >> > The control tree is already created in PreInit event, as the
>>> >>> >> > aspx
>>> >>> >> > page
>>> >>> >> > compiler puts all the declarations into FrameworkInitialize()
>>> >>> >> > method
>>> >>> >> > which
>>> >>> >> > is
>>> >>> >> > called from Page.ProcessRequest (member of the IHttpHandler
>>> >>> >> > interface)
>>> >>> >> > (have
>>> >>> >> > a look at the content of your website's asp.net folder,
>>> >>> >> > especially
>>> >>> >> > at
>>> >>> >> > compiled pages). Therefore, it's safe to run the code:
>>> >>> >> > Request.Form[ddl.uniqueID]
>>> >>> >> >
>>> >>> >> > Regards
>>> >>> >> > --
>>> >>> >> > Milosz
>>> >>> >> >
>>> >>> >> >
>>> >>> >> > "Chad Scharf" wrote:
>>> >>> >> >
>>> >>> >> >> Yes, that would be easier. Sorry, I typically never use
>>> >>> >> >> Request.Form
>>> >>> >> >> and
>>> >>> >> >> forgot about it.
>>> >>> >> >>
>>> >>> >> >> Is the UniqueID available though in the Page_PreInit event,
>>> >>> >> >> seeing
>>> >>> >> >> as
>>> >>> >> >> the
>>> >>> >> >> control tree has not yet been built, it would be difficult for
>>> >>> >> >> the
>>> >>> >> >> Page
>>> >>> >> >> to
>>> >>> >> >> calculate the UniqueID, and typically the Control instance
>>> >>> >> >> would
>>> >>> >> >> be
>>> >>> >> >> null
>>> >>> >> >> as
>>> >>> >> >> well no?
>>> >>> >> >>
>>> >>> >> >> --
>>> >>> >> >> Chad Scharf
>>> >>> >> >> _______________________________
>>> >>> >> >> http://www.chadscharf.com
>>> >>> >> >>
>>> >>> >> >>
>>> >>> >> >> "Milosz Skalecki [MCAD]" wrote:
>>> >>> >> >>
>>> >>> >> >> > Howdy,
>>> >>> >> >> >
>>> >>> >> >> > Why using cookie, wouldn't be easier just by using
>>> >>> >> >> > string selectedValue = Request.Form[yourDropDown.UniqueID]
>>> >>> >> >> > ?
>>> >>> >> >> >
>>> >>> >> >> >
>>> >>> >> >> > --
>>> >>> >> >> > Milosz
>>> >>> >> >> >
>>> >>> >> >> >
>>> >>> >> >> > "Chad Scharf" wrote:
>>> >>> >> >> >
>>> >>> >> >> > > Unfortunately I believe the answer is no. Is there a
>>> >>> >> >> > > reason
>>> >>> >> >> > > you
>>> >>> >> >> > > need
>>> >>> >> >> > > this
>>> >>> >> >> > > value before the page is initialized?
>>> >>> >> >> > >
>>> >>> >> >> > > You could potentially inject the value into a cookie using
>>> >>> >> >> > > JavaScript
>>> >>> >> >> > > using
>>> >>> >> >> > > the OnSubmit event of your form, then read that using the
>>> >>> >> >> > > HttpContext.Current.Request.Cookies collection to retrieve
>>> >>> >> >> > > your
>>> >>> >> >> > > value
>>> >>> >> >> > > upon
>>> >>> >> >> > > post-back. I believe the HttpRequest stack has been
>>> >>> >> >> > > created by
>>> >>> >> >> > > then
>>> >>> >> >> > > and upon
>>> >>> >> >> > > calling the OnPreInit method of your page, has built these
>>> >>> >> >> > > values
>>> >>> >> >> > > from the
>>> >>> >> >> > > request headers.
>>> >>> >> >> > >
>>> >>> >> >> > > --
>>> >>> >> >> > > Chad Scharf
>>> >>> >> >> > > _______________________________
>>> >>> >> >> > > http://www.chadscharf.com
>>> >>> >> >> > >
>>> >>> >> >> > >
>>> >>> >> >> > > "Redhairs" wrote:
>>> >>> >> >> > >
>>> >>> >> >> > > > Is it possible to get DropDownList.SelectedValue in
>>> >>> >> >> > > > Page_PreInit()
>>> >>> >> >> > > > event
>>> >>> >> >> > > > during the postback?
>>> >>> >> >> > > >
>>> >>> >> >> > > >
>>> >>> >> >> > > >
>>> >>> >>
>>> >>> >>
>>> >>> >>
>>> >>>
>>> >>>
>>> >>>
>>> >
>>> >
>>>
>>>
>>>
>
>
Red,
Finally, you explained what you've been trying to achive. There are two or
three solutions but i need to know answers on following questions:
- is 'select master page/layout' drop down list put on every single page
- do different master pages from the list have the same placeholders
- could you explain a little bit how 'select layout' functionality should
work.
I'm asking because MasterPageFile is not persited anywhere the default value
is taken from <%@ Page %> MasterPageFile attribute, but you're trying to use
dropdown's selected value to set MasetrPageFile property without knowing
where to look (i.e before the postback non-default master was used).
Waiting for your reply
--
Milosz
"Redhairs" wrote:
> Actually, the DDL.UniqueID="Value" do exist in the Request.Form collection
> but
> can't retrieve it via Request.Form[DDL.UniqueID], is it because server will
> validate
> the viewstate?
>
>
>
> "Redhairs"
> news:uCLL%23BjWIHA.5208@TK2MSFTNGP04.phx.gbl...
> >I finally found a clue but not sure if it's correct or not.
> >
> > My goal is to dynamically apply master page in Page_PreInit() with the
> > selected value of drop-down list.
> > (the drop-down-list control is placed in the Content control), so during
> > the postback, I need to read the
> > selected value of drop-down list in Page_PreInit() event then set the
> > Page.MasterPageFile property.
> >
> > Since the dropdownlist is not created yet in Page_PreInit() and I need to
> > use Master.FindControl......
> > way to retrieve the UniqueID and value from Request.Form collection. But
> > at this time I haven't set the
> > master page, so the Master is a null object and I can't find the
> > dropdownlist.UniqueID.
> >
> > Any workaround? I can only append the selected value as the querystring
> > but no postback any more?
> >
> >
> >
> >
> > "Milosz Skalecki [MCAD]"
> > news:9C78BD50-AE15-40FF-A379-34E7DA8C43AE@microsoft.com...
> >> Hi Red,
> >>
> >> I don't know what is happening in your code but everything is hunky-dory
> >> in
> >> mine. Could you please paste entire code from both aspx page and code
> >> beside.
> >>
> >> Regards
> >> --
> >> Milosz
> >>
> >>
> >> "Redhairs" wrote:
> >>
> >>> I find if I change the drop-down list first time, the page will postback
> >>> and
> >>> get the
> >>> Request.Form[_theDDL.UnigueID] correctly in Page_PreInit(). but the
> >>> drop-downlist
> >>> won't change and onSelectionIndexChanged won't be triggered.
> >>>
> >>> Then I change the drow-down list again, this time CAN NOT find the
> >>> Request.Form[_theDDL.UnigueID] correctly in Page_PreInit().
> >>> butbut the drop-downlist change and onSelectionIndexChanged is raised.
> >>>
> >>> Do I miss any thing here?
> >>>
> >>>
> >>>
> >>> "Redhairs"
> >>> news:O$C0qOVWIHA.4740@TK2MSFTNGP02.phx.gbl...
> >>> > The source codes are as below, the page is inherited from one base
> >>> > class
> >>> >
> >>> > Test.aspx:
> >>> >
> >>> >
> >>> > OnSelectionIndexChanged="......"/>
> >>> >
> >>> >
> >>> >
> >>> > Test.aspx.cs
> >>> > void Page_PreInit(object sender, EventArg e)
> >>> > {
> >>> >
> >>> > DropDownList _theDDL = (DropDownList)
> >>> > Master.FindControl("TheHolder").FindControl("langSelection") ;
> >>> > if (_theDDL != null)
> >>> > Response.Write(Request.Form[_theDDL.UnigueID]); // null Object
> >>> > reference err here
> >>> > }
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> > "Milosz Skalecki [MCAD]"
> >>> > news:9CB89864-FA79-441B-A3AF-DD636BB84220@microsoft.com...
> >>> >> Howdy,
> >>> >>
> >>> >> In this case (masterpage) you have to manually find the control as it
> >>> >> has
> >>> >> not been referenced yet (but it has been instantiated in the contrnt
> >>> >> place
> >>> >> holder):
> >>> >>
> >>> >> string selectedValue =
> >>> >> Request.Form[Master.FindControl("placeholdername").FindContr ol("ddlID").UniqueID];
> >>> >>
> >>> >> It's quite nasty, so my question is why would you need that? The
> >>> >> difference
> >>> >> bewteen UniqueID and ClientID is the first is used as "name"
> >>> >> attribute
> >>> >> for
> >>> >> input controls and it consists of ID + parents ID (simpifying)
> >>> >> separated
> >>> >> by a
> >>> >> dollar character, whilst ClientID is used as "id" attribute of all
> >>> >> the
> >>> >> html
> >>> >> elements that are generated by web controls/html controls with
> >>> >> runat=server
> >>> >> separated by underscore char. For more info check this out:
> >>> >> http://www.shanebauer.com/Weblog/PermaLink,guid,488f7bb3-dac 8-400b-aacf-e94d4da9b533.aspx
> >>> >> --
> >>> >> Milosz
> >>> >>
> >>> >>
> >>> >> "Redhairs" wrote:
> >>> >>
> >>> >>> Yes, I use use the master page so the DropDownList was placed in the
> >>> >>> Content
> >>> >>> control,
> >>> >>> how to solve this problem?
> >>> >>> Btw, waht's the difference between ClientID and UniqueID?
> >>> >>>
> >>> >>>
> >>> >>> "Milosz Skalecki [MCAD]"
> >>> >>> message
> >>> >>> news:BC6247CA-61E5-4908-9C04-C5FF9782BB89@microsoft.com...
> >>> >>> > Hi Redhairs,
> >>> >>> >
> >>> >>> > I checked it and it works fine. Are you by any chance create this
> >>> >>> > control
> >>> >>> > dynamically or drop down list is placed inside a tamplated
> >>> >>> > control?
> >>> >>> > Could
> >>> >>> > you
> >>> >>> > please pase some code?
> >>> >>> >
> >>> >>> > Regards
> >>> >>> > --
> >>> >>> > Milosz
> >>> >>> >
> >>> >>> >
> >>> >>> > "Redhairs" wrote:
> >>> >>> >
> >>> >>> >> It doesn't work and return error msg "Object reference not set to
> >>> >>> >> an
> >>> >>> >> instance of an object"
> >>> >>> >> "Milosz Skalecki [MCAD]"
> >>> >>> >> message
> >>> >>> >> news:EF293811-3B1C-4454-B199-FFBD99D95D4E@microsoft.com...
> >>> >>> >> > Hi Chad,
> >>> >>> >> >
> >>> >>> >> > The control tree is already created in PreInit event, as the
> >>> >>> >> > aspx
> >>> >>> >> > page
> >>> >>> >> > compiler puts all the declarations into FrameworkInitialize()
> >>> >>> >> > method
> >>> >>> >> > which
> >>> >>> >> > is
> >>> >>> >> > called from Page.ProcessRequest (member of the IHttpHandler
> >>> >>> >> > interface)
> >>> >>> >> > (have
> >>> >>> >> > a look at the content of your website's asp.net folder,
> >>> >>> >> > especially
> >>> >>> >> > at
> >>> >>> >> > compiled pages). Therefore, it's safe to run the code:
> >>> >>> >> > Request.Form[ddl.uniqueID]
> >>> >>> >> >
> >>> >>> >> > Regards
> >>> >>> >> > --
> >>> >>> >> > Milosz
> >>> >>> >> >
> >>> >>> >> >
> >>> >>> >> > "Chad Scharf" wrote:
> >>> >>> >> >
> >>> >>> >> >> Yes, that would be easier. Sorry, I typically never use
> >>> >>> >> >> Request.Form
> >>> >>> >> >> and
> >>> >>> >> >> forgot about it.
> >>> >>> >> >>
> >>> >>> >> >> Is the UniqueID available though in the Page_PreInit event,
> >>> >>> >> >> seeing
> >>> >>> >> >> as
> >>> >>> >> >> the
> >>> >>> >> >> control tree has not yet been built, it would be difficult for
> >>> >>> >> >> the
> >>> >>> >> >> Page
> >>> >>> >> >> to
> >>> >>> >> >> calculate the UniqueID, and typically the Control instance
> >>> >>> >> >> would
> >>> >>> >> >> be
> >>> >>> >> >> null
> >>> >>> >> >> as
> >>> >>> >> >> well no?
> >>> >>> >> >>
> >>> >>> >> >> --
> >>> >>> >> >> Chad Scharf
> >>> >>> >> >> _______________________________
> >>> >>> >> >> http://www.chadscharf.com
> >>> >>> >> >>
> >>> >>> >> >>
> >>> >>> >> >> "Milosz Skalecki [MCAD]" wrote:
> >>> >>> >> >>
> >>> >>> >> >> > Howdy,
> >>> >>> >> >> >
> >>> >>> >> >> > Why using cookie, wouldn't be easier just by using
> >>> >>> >> >> > string selectedValue = Request.Form[yourDropDown.UniqueID]
> >>> >>> >> >> > ?
> >>> >>> >> >> >
> >>> >>> >> >> >
> >>> >>> >> >> > --
> >>> >>> >> >> > Milosz
> >>> >>> >> >> >
> >>> >>> >> >> >
> >>> >>> >> >> > "Chad Scharf" wrote:
> >>> >>> >> >> >
> >>> >>> >> >> > > Unfortunately I believe the answer is no. Is there a
> >>> >>> >> >> > > reason
> >>> >>> >> >> > > you
> >>> >>> >> >> > > need
> >>> >>> >> >> > > this
> >>> >>> >> >> > > value before the page is initialized?
> >>> >>> >> >> > >
> >>> >>> >> >> > > You could potentially inject the value into a cookie using
> >>> >>> >> >> > > JavaScript
> >>> >>> >> >> > > using
> >>> >>> >> >> > > the OnSubmit event of your form, then read that using the
> >>> >>> >> >> > > HttpContext.Current.Request.Cookies collection to retrieve
> >>> >>> >> >> > > your
> >>> >>> >> >> > > value
> >>> >>> >> >> > > upon
> >>> >>> >> >> > > post-back. I believe the HttpRequest stack has been
> >>> >>> >> >> > > created by
> >>> >>> >> >> > > then
> >>> >>> >> >> > > and upon
> >>> >>> >> >> > > calling the OnPreInit method of your page, has built these
> >>> >>> >> >> > > values
> >>> >>> >> >> > > from the
> >>> >>> >> >> > > request headers.
> >>> >>> >> >> > >
> >>> >>> >> >> > > --
> >>> >>> >> >> > > Chad Scharf
> >>> >>> >> >> > > _______________________________
> >>> >>> >> >> > > http://www.chadscharf.com
> >>> >>> >> >> > >
> >>> >>> >> >> > >
> >>> >>> >> >> > > "Redhairs" wrote:
> >>> >>> >> >> > >
> >>> >>> >> >> > > > Is it possible to get DropDownList.SelectedValue in
> >>> >>> >> >> > > > Page_PreInit()
> >>> >>> >> >> > > > event
> >>> >>> >> >> > > > during the postback?
> >>> >>> >> >> > > >
> >>> >>> >> >> > > >
> >>> >>> >> >> > > >
> >>> >>> >>
> >>> >>> >>
> >>> >>> >>
> >>> >>>
> >>> >>>
> >>> >>>
> >>> >
> >>> >
> >>>
> >>>
> >>>
> >
> >
>
>
>
I have created several master pages and this page will assign default master
page
in page_PreInit() during the first time access. The dropdownlist will be
initialized
to display the available master page names during the Page_Load().
When the onSelectedIndexChanges event of dropdownlist will autopostback and
assign the master page with selected value in Page_PreInit().
The problem here is not able to read the selected value of dropdownlist in
Page_PreInit()
"Milosz Skalecki [MCAD]"
news:B85B5F28-6A4B-4B76-8DA5-797CFB784E8D@microsoft.com...
> Red,
>
> Finally, you explained what you've been trying to achive. There are two or
> three solutions but i need to know answers on following questions:
> - is 'select master page/layout' drop down list put on every single page
> - do different master pages from the list have the same placeholders
> - could you explain a little bit how 'select layout' functionality should
> work.
> I'm asking because MasterPageFile is not persited anywhere the default
> value
> is taken from <%@ Page %> MasterPageFile attribute, but you're trying to
> use
> dropdown's selected value to set MasetrPageFile property without knowing
> where to look (i.e before the postback non-default master was used).
>
> Waiting for your reply
> --
> Milosz
>
>
> "Redhairs" wrote:
>
>> Actually, the DDL.UniqueID="Value" do exist in the Request.Form
>> collection
>> but
>> can't retrieve it via Request.Form[DDL.UniqueID], is it because server
>> will
>> validate
>> the viewstate?
>>
>>
>>
>> "Redhairs"
>> news:uCLL%23BjWIHA.5208@TK2MSFTNGP04.phx.gbl...
>> >I finally found a clue but not sure if it's correct or not.
>> >
>> > My goal is to dynamically apply master page in Page_PreInit() with the
>> > selected value of drop-down list.
>> > (the drop-down-list control is placed in the Content control), so
>> > during
>> > the postback, I need to read the
>> > selected value of drop-down list in Page_PreInit() event then set the
>> > Page.MasterPageFile property.
>> >
>> > Since the dropdownlist is not created yet in Page_PreInit() and I need
>> > to
>> > use Master.FindControl......
>> > way to retrieve the UniqueID and value from Request.Form collection.
>> > But
>> > at this time I haven't set the
>> > master page, so the Master is a null object and I can't find the
>> > dropdownlist.UniqueID.
>> >
>> > Any workaround? I can only append the selected value as the querystring
>> > but no postback any more?
>> >
>> >
>> >
>> >
>> > "Milosz Skalecki [MCAD]"
>> > news:9C78BD50-AE15-40FF-A379-34E7DA8C43AE@microsoft.com...
>> >> Hi Red,
>> >>
>> >> I don't know what is happening in your code but everything is
>> >> hunky-dory
>> >> in
>> >> mine. Could you please paste entire code from both aspx page and code
>> >> beside.
>> >>
>> >> Regards
>> >> --
>> >> Milosz
>> >>
>> >>
>> >> "Redhairs" wrote:
>> >>
>> >>> I find if I change the drop-down list first time, the page will
>> >>> postback
>> >>> and
>> >>> get the
>> >>> Request.Form[_theDDL.UnigueID] correctly in Page_PreInit(). but the
>> >>> drop-downlist
>> >>> won't change and onSelectionIndexChanged won't be triggered.
>> >>>
>> >>> Then I change the drow-down list again, this time CAN NOT find the
>> >>> Request.Form[_theDDL.UnigueID] correctly in Page_PreInit().
>> >>> butbut the drop-downlist change and onSelectionIndexChanged is
>> >>> raised.
>> >>>
>> >>> Do I miss any thing here?
>> >>>
>> >>>
>> >>>
>> >>> "Redhairs"
>> >>> news:O$C0qOVWIHA.4740@TK2MSFTNGP02.phx.gbl...
>> >>> > The source codes are as below, the page is inherited from one base
>> >>> > class
>> >>> >
>> >>> > Test.aspx:
>> >>> >
>> >>> >
>> >>> > OnSelectionIndexChanged="......"/>
>> >>> >
>> >>> >
>> >>> >
>> >>> > Test.aspx.cs
>> >>> > void Page_PreInit(object sender, EventArg e)
>> >>> > {
>> >>> >
>> >>> > DropDownList _theDDL = (DropDownList)
>> >>> > Master.FindControl("TheHolder").FindControl("langSelection") ;
>> >>> > if (_theDDL != null)
>> >>> > Response.Write(Request.Form[_theDDL.UnigueID]); // null Object
>> >>> > reference err here
>> >>> > }
>> >>> >
>> >>> >
>> >>> >
>> >>> >
>> >>> >
>> >>> >
>> >>> >
>> >>> > "Milosz Skalecki [MCAD]"
>> >>> > message
>> >>> > news:9CB89864-FA79-441B-A3AF-DD636BB84220@microsoft.com...
>> >>> >> Howdy,
>> >>> >>
>> >>> >> In this case (masterpage) you have to manually find the control as
>> >>> >> it
>> >>> >> has
>> >>> >> not been referenced yet (but it has been instantiated in the
>> >>> >> contrnt
>> >>> >> place
>> >>> >> holder):
>> >>> >>
>> >>> >> string selectedValue =
>> >>> >> Request.Form[Master.FindControl("placeholdername").FindContr ol("ddlID").UniqueID];
>> >>> >>
>> >>> >> It's quite nasty, so my question is why would you need that? The
>> >>> >> difference
>> >>> >> bewteen UniqueID and ClientID is the first is used as "name"
>> >>> >> attribute
>> >>> >> for
>> >>> >> input controls and it consists of ID + parents ID (simpifying)
>> >>> >> separated
>> >>> >> by a
>> >>> >> dollar character, whilst ClientID is used as "id" attribute of all
>> >>> >> the
>> >>> >> html
>> >>> >> elements that are generated by web controls/html controls with
>> >>> >> runat=server
>> >>> >> separated by underscore char. For more info check this out:
>> >>> >> http://www.shanebauer.com/Weblog/PermaLink,guid,488f7bb3-dac 8-400b-aacf-e94d4da9b533.aspx
>> >>> >> --
>> >>> >> Milosz
>> >>> >>
>> >>> >>
>> >>> >> "Redhairs" wrote:
>> >>> >>
>> >>> >>> Yes, I use use the master page so the DropDownList was placed in
>> >>> >>> the
>> >>> >>> Content
>> >>> >>> control,
>> >>> >>> how to solve this problem?
>> >>> >>> Btw, waht's the difference between ClientID and UniqueID?
>> >>> >>>
>> >>> >>>
>> >>> >>> "Milosz Skalecki [MCAD]"
>> >>> >>> message
>> >>> >>> news:BC6247CA-61E5-4908-9C04-C5FF9782BB89@microsoft.com...
>> >>> >>> > Hi Redhairs,
>> >>> >>> >
>> >>> >>> > I checked it and it works fine. Are you by any chance create
>> >>> >>> > this
>> >>> >>> > control
>> >>> >>> > dynamically or drop down list is placed inside a tamplated
>> >>> >>> > control?
>> >>> >>> > Could
>> >>> >>> > you
>> >>> >>> > please pase some code?
>> >>> >>> >
>> >>> >>> > Regards
>> >>> >>> > --
>> >>> >>> > Milosz
>> >>> >>> >
>> >>> >>> >
>> >>> >>> > "Redhairs" wrote:
>> >>> >>> >
>> >>> >>> >> It doesn't work and return error msg "Object reference not set
>> >>> >>> >> to
>> >>> >>> >> an
>> >>> >>> >> instance of an object"
>> >>> >>> >> "Milosz Skalecki [MCAD]"
>> >>> >>> >> message
>> >>> >>> >> news:EF293811-3B1C-4454-B199-FFBD99D95D4E@microsoft.com...
>> >>> >>> >> > Hi Chad,
>> >>> >>> >> >
>> >>> >>> >> > The control tree is already created in PreInit event, as the
>> >>> >>> >> > aspx
>> >>> >>> >> > page
>> >>> >>> >> > compiler puts all the declarations into
>> >>> >>> >> > FrameworkInitialize()
>> >>> >>> >> > method
>> >>> >>> >> > which
>> >>> >>> >> > is
>> >>> >>> >> > called from Page.ProcessRequest (member of the IHttpHandler
>> >>> >>> >> > interface)
>> >>> >>> >> > (have
>> >>> >>> >> > a look at the content of your website's asp.net folder,
>> >>> >>> >> > especially
>> >>> >>> >> > at
>> >>> >>> >> > compiled pages). Therefore, it's safe to run the code:
>> >>> >>> >> > Request.Form[ddl.uniqueID]
>> >>> >>> >> >
>> >>> >>> >> > Regards
>> >>> >>> >> > --
>> >>> >>> >> > Milosz
>> >>> >>> >> >
>> >>> >>> >> >
>> >>> >>> >> > "Chad Scharf" wrote:
>> >>> >>> >> >
>> >>> >>> >> >> Yes, that would be easier. Sorry, I typically never use
>> >>> >>> >> >> Request.Form
>> >>> >>> >> >> and
>> >>> >>> >> >> forgot about it.
>> >>> >>> >> >>
>> >>> >>> >> >> Is the UniqueID available though in the Page_PreInit event,
>> >>> >>> >> >> seeing
>> >>> >>> >> >> as
>> >>> >>> >> >> the
>> >>> >>> >> >> control tree has not yet been built, it would be difficult
>> >>> >>> >> >> for
>> >>> >>> >> >> the
>> >>> >>> >> >> Page
>> >>> >>> >> >> to
>> >>> >>> >> >> calculate the UniqueID, and typically the Control instance
>> >>> >>> >> >> would
>> >>> >>> >> >> be
>> >>> >>> >> >> null
>> >>> >>> >> >> as
>> >>> >>> >> >> well no?
>> >>> >>> >> >>
>> >>> >>> >> >> --
>> >>> >>> >> >> Chad Scharf
>> >>> >>> >> >> _______________________________
>> >>> >>> >> >> http://www.chadscharf.com
>> >>> >>> >> >>
>> >>> >>> >> >>
>> >>> >>> >> >> "Milosz Skalecki [MCAD]" wrote:
>> >>> >>> >> >>
>> >>> >>> >> >> > Howdy,
>> >>> >>> >> >> >
>> >>> >>> >> >> > Why using cookie, wouldn't be easier just by using
>> >>> >>> >> >> > string selectedValue =
>> >>> >>> >> >> > Request.Form[yourDropDown.UniqueID]
>> >>> >>> >> >> > ?
>> >>> >>> >> >> >
>> >>> >>> >> >> >
>> >>> >>> >> >> > --
>> >>> >>> >> >> > Milosz
>> >>> >>> >> >> >
>> >>> >>> >> >> >
>> >>> >>> >> >> > "Chad Scharf" wrote:
>> >>> >>> >> >> >
>> >>> >>> >> >> > > Unfortunately I believe the answer is no. Is there a
>> >>> >>> >> >> > > reason
>> >>> >>> >> >> > > you
>> >>> >>> >> >> > > need
>> >>> >>> >> >> > > this
>> >>> >>> >> >> > > value before the page is initialized?
>> >>> >>> >> >> > >
>> >>> >>> >> >> > > You could potentially inject the value into a cookie
>> >>> >>> >> >> > > using
>> >>> >>> >> >> > > JavaScript
>> >>> >>> >> >> > > using
>> >>> >>> >> >> > > the OnSubmit event of your form, then read that using
>> >>> >>> >> >> > > the
>> >>> >>> >> >> > > HttpContext.Current.Request.Cookies collection to
>> >>> >>> >> >> > > retrieve
>> >>> >>> >> >> > > your
>> >>> >>> >> >> > > value
>> >>> >>> >> >> > > upon
>> >>> >>> >> >> > > post-back. I believe the HttpRequest stack has been
>> >>> >>> >> >> > > created by
>> >>> >>> >> >> > > then
>> >>> >>> >> >> > > and upon
>> >>> >>> >> >> > > calling the OnPreInit method of your page, has built
>> >>> >>> >> >> > > these
>> >>> >>> >> >> > > values
>> >>> >>> >> >> > > from the
>> >>> >>> >> >> > > request headers.
>> >>> >>> >> >> > >
>> >>> >>> >> >> > > --
>> >>> >>> >> >> > > Chad Scharf
>> >>> >>> >> >> > > _______________________________
>> >>> >>> >> >> > > http://www.chadscharf.com
>> >>> >>> >> >> > >
>> >>> >>> >> >> > >
>> >>> >>> >> >> > > "Redhairs" wrote:
>> >>> >>> >> >> > >
>> >>> >>> >> >> > > > Is it possible to get DropDownList.SelectedValue in
>> >>> >>> >> >> > > > Page_PreInit()
>> >>> >>> >> >> > > > event
>> >>> >>> >> >> > > > during the postback?
>> >>> >>> >> >> > > >
>> >>> >>> >> >> > > >
>> >>> >>> >> >> > > >
>> >>> >>> >>
>> >>> >>> >>
>> >>> >>> >>
>> >>> >>>
>> >>> >>>
>> >>> >>>
>> >>> >
>> >>> >
>> >>>
>> >>>
>> >>>
>> >
>> >
>>
>>
>>