p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

aspdotnet_website_programming thread: Custom User Controls Fail to initialize on PostBack


Message #1 by "Kirk Gomez" <hed2hed@c...> on Sun, 12 May 2002 03:56:16
Code follows message...

Thx Minh for the advice on ViewState.  Here's my other stumper.  Here's a 
peice of code that works fine when the page is brought up.  I have two 
customer user controls within another custom user control.  An event fires 
that causes a post back on the PressRelease page.  However, the <%# 
FLeagueID %> fails to pass into swamiViewBets?!?!?!?  Is this part of the 
PostBack behavior.  How can I get the value into the user control on a 
PostBack (w/o using cookies!)  I have a similiar problem further in the 
code where I have a 3rd user control within a Repeater attempting the same 
thing.

Help!

Kirk Gomez
hed2hed@c...

<%@ Control Inherits="PressReleases" src="PressReleases.vb" %>
<swami:titleFLeague id="titleFLeague" runat="server"
       FLeagueID   = <%# FLeagueID %>
       Header      = "The Press Room"
       />
<swami:swamiViewBets id="swamiViewBets" runat="server"
       FLeagueID = <%# FLeagueID %>
       ShowTitle = "False"
       />
<table class="Standard" cellspacing=1 width="100%">
  <tr>
    <td>
     ....
Message #2 by "Kirk Gomez" <hed2hed@c...> on Sun, 12 May 2002 04:10:25
*** UPDATE *** 

The first controls do pass in the proper value.  BUT the problem still 
persists for the custom control within an ASP:Repeater.  Values have been 
confirmed to exist.  Thanks for the help.

*** UPDATE ***

> Code follows message...

> Thx Minh for the advice on ViewState.  Here's my other stumper.  Here's 
a 
p> eice of code that works fine when the page is brought up.  I have two 
c> ustomer user controls within another custom user control.  An event 
fires 
t> hat causes a post back on the PressRelease page.  However, the <%# 
F> LeagueID %> fails to pass into swamiViewBets?!?!?!?  Is this part of 
the 
P> ostBack behavior.  How can I get the value into the user control on a 
P> ostBack (w/o using cookies!)  I have a similiar problem further in the 
c> ode where I have a 3rd user control within a Repeater attempting the 
same 
t> hing.

> Help!

> Kirk Gomez
h> ed2hed@c...

> <%@ Control Inherits="PressReleases" src="PressReleases.vb" %>
<> swami:titleFLeague id="titleFLeague" runat="server"
 >       FLeagueID   = <%# FLeagueID %>
 >       Header      = "The Press Room"
 >       />
<> swami:swamiViewBets id="swamiViewBets" runat="server"
 >       FLeagueID = <%# FLeagueID %>
 >       ShowTitle = "False"
 >       />
<> table class="Standard" cellspacing=1 width="100%">
 >  <tr>
 >    <td>
 >     ....
Message #3 by "Kirk Gomez" <hed2hed@c...> on Sun, 12 May 2002 04:37:16
*** UPDATE #2 ***

Code Follows...

The behavior appears to be limited to User Controls within a Repeater.  
swamiPressRelease is contained within the rprPressRelease repeater.  The 
function "GetID" is firing and returning correct values.  However the 
value is never assigned to PressReleaseID.  This is not the only instance 
where this happens.  Several other pages are encountering the same error, 
all w/in Repeater controls.  Looks like a bug in the 1.0 release unless 
I'm missing something.  Again... the initial page load works fine and data 
is displayed properly.  HELP!  Thx

Kirk Gomez
hed2hed@c...

  <asp:Repeater id="rprPressRelease" runat="server">
    <ItemTemplate>
      <tr>
        <asp:TableCell id="tcPressRelease" runat="server">
          <swami:swamiPressRelease id="swamiPressRelease" runat="server"
                 PressReleaseID = <%# GetID( Container.DataItem
( "PressReleaseID" ).ToString() ) %>
                 />
        </asp:TableCell>
      </tr>
    </ItemTemplate>
  </asp:Repeater>


*** UPDATE #2 ***

> *** UPDATE *** 

> The first controls do pass in the proper value.  BUT the problem still 
p> ersists for the custom control within an ASP:Repeater.  Values have 
been 
c> onfirmed to exist.  Thanks for the help.

> *** UPDATE ***

> > Code follows message...

> > Thx Minh for the advice on ViewState.  Here's my other stumper.  
Here's 
a>  
p> > eice of code that works fine when the page is brought up.  I have two 
c> > ustomer user controls within another custom user control.  An event 
f> ires 
t> > hat causes a post back on the PressRelease page.  However, the <%# 
F> > LeagueID %> fails to pass into swamiViewBets?!?!?!?  Is this part of 
t> he 
P> > ostBack behavior.  How can I get the value into the user control on a 
P> > ostBack (w/o using cookies!)  I have a similiar problem further in 
the 
c> > ode where I have a 3rd user control within a Repeater attempting the 
s> ame 
t> > hing.

> > Help!

> > Kirk Gomez
h> > ed2hed@c...

> > <%@ Control Inherits="PressReleases" src="PressReleases.vb" %>
<> > swami:titleFLeague id="titleFLeague" runat="server"
 > >       FLeagueID   = <%# FLeagueID %>
 > >       Header      = "The Press Room"
 > >       />
<> > swami:swamiViewBets id="swamiViewBets" runat="server"
 > >       FLeagueID = <%# FLeagueID %>
 > >       ShowTitle = "False"
 > >       />
<> > table class="Standard" cellspacing=1 width="100%">
 > >  <tr>
 > >    <td>
 > >     ....
Message #4 by "Minh T. Nguyen" <nguyentriminh@y...> on Sun, 12 May 2002 22:52:19 -0700
Kirk,

	I believe (I am guessing now) that you have to put quotes around
<%# FLeagueID %>. I assume that your variable FLeagueID that you have
obtained back from your viewstate/session/application/cookie repository
is a public (or at least protected) variable in your code-behind, right?

	Alternatively, you can set that attribute in your code-behind
file. Something like this:

	Page_Load(...) {
		titleFLeague.FLeagueID = FLeagueID;
		swamiViewBets.FLeagueID = FLeagueID;
	}

Hope this helps,
Minh.

-----Original Message-----
From: Kirk Gomez [mailto:hed2hed@c...] 
Sent: Sunday, May 12, 2002 3:56 AM
To: Website Programming with ASP.NET
Subject: [aspdotnet_website_programming] Custom User Controls Fail to
initialize on PostBack


Code follows message...

Thx Minh for the advice on ViewState.  Here's my other stumper.  Here's
a 
peice of code that works fine when the page is brought up.  I have two 
customer user controls within another custom user control.  An event
fires 
that causes a post back on the PressRelease page.  However, the <%# 
FLeagueID %> fails to pass into swamiViewBets?!?!?!?  Is this part of
the 
PostBack behavior.  How can I get the value into the user control on a 
PostBack (w/o using cookies!)  I have a similiar problem further in the 
code where I have a 3rd user control within a Repeater attempting the
same 
thing.

Help!

Kirk Gomez
hed2hed@c...

<%@ Control Inherits="PressReleases" src="PressReleases.vb" %>
<swami:titleFLeague id="titleFLeague" runat="server"
       FLeagueID   = <%# FLeagueID %>
       Header      = "The Press Room"
       />
<swami:swamiViewBets id="swamiViewBets" runat="server"
       FLeagueID = <%# FLeagueID %>
       ShowTitle = "False"
       />
<table class="Standard" cellspacing=1 width="100%">
  <tr>
    <td>
     ....

Message #5 by "Minh T. Nguyen" <nguyentriminh@y...> on Sun, 12 May 2002 23:01:17 -0700
Kirk,

	How do you get the PressReleaseID value? Can you set a break
point at that statement and verify that that value actually gets
assigned on your postback? Maybe you are not getting the value correctly
from your viewstate/cookie/session/application repository? 

Minh.

-----Original Message-----
From: Kirk Gomez [mailto:hed2hed@c...] 
Sent: Sunday, May 12, 2002 4:37 AM
To: Website Programming with ASP.NET
Subject: [aspdotnet_website_programming] Re: Custom User Controls Fail
to initialize on PostBack


*** UPDATE #2 ***

Code Follows...

The behavior appears to be limited to User Controls within a Repeater.  
swamiPressRelease is contained within the rprPressRelease repeater.  The

function "GetID" is firing and returning correct values.  However the 
value is never assigned to PressReleaseID.  This is not the only
instance 
where this happens.  Several other pages are encountering the same
error, 
all w/in Repeater controls.  Looks like a bug in the 1.0 release unless 
I'm missing something.  Again... the initial page load works fine and
data 
is displayed properly.  HELP!  Thx

Kirk Gomez
hed2hed@c...

  <asp:Repeater id="rprPressRelease" runat="server">
    <ItemTemplate>
      <tr>
        <asp:TableCell id="tcPressRelease" runat="server">
          <swami:swamiPressRelease id="swamiPressRelease" runat="server"
                 PressReleaseID = <%# GetID( Container.DataItem
( "PressReleaseID" ).ToString() ) %>
                 />
        </asp:TableCell>
      </tr>
    </ItemTemplate>
  </asp:Repeater>


*** UPDATE #2 ***

> *** UPDATE *** 

> The first controls do pass in the proper value.  BUT the problem still

p> ersists for the custom control within an ASP:Repeater.  Values have 
been 
c> onfirmed to exist.  Thanks for the help.

> *** UPDATE ***

> > Code follows message...

> > Thx Minh for the advice on ViewState.  Here's my other stumper.  
Here's 
a>  
p> > eice of code that works fine when the page is brought up.  I have
two 
c> > ustomer user controls within another custom user control.  An event

f> ires 
t> > hat causes a post back on the PressRelease page.  However, the <%# 
F> > LeagueID %> fails to pass into swamiViewBets?!?!?!?  Is this part
of 
t> he 
P> > ostBack behavior.  How can I get the value into the user control on
a 
P> > ostBack (w/o using cookies!)  I have a similiar problem further in 
the 
c> > ode where I have a 3rd user control within a Repeater attempting
the 
s> ame 
t> > hing.

> > Help!

> > Kirk Gomez
h> > ed2hed@c...

> > <%@ Control Inherits="PressReleases" src="PressReleases.vb" %>
<> > swami:titleFLeague id="titleFLeague" runat="server"
 > >       FLeagueID   = <%# FLeagueID %>
 > >       Header      = "The Press Room"
 > >       />
<> > swami:swamiViewBets id="swamiViewBets" runat="server"
 > >       FLeagueID = <%# FLeagueID %>
 > >       ShowTitle = "False"
 > >       />
<> > table class="Standard" cellspacing=1 width="100%">
 > >  <tr>
 > >    <td>
 > >     ....


  Return to Index