Last post Jan 04, 2007 12:04 PM by jrblack10
Nov 03, 2005 02:52 PM|e106199|LINK
Nov 03, 2005 06:08 PM|booler|LINK
Nov 03, 2005 06:11 PM|ashley.flynn|LINK
Nov 04, 2005 12:32 AM|e106199|LINK
Nov 04, 2005 12:47 AM|e106199|LINK
Nov 04, 2005 03:03 AM|ashley.flynn|LINK
Nov 04, 2005 07:28 AM|mbanavige|LINK
To be honest, populating the usercontrol by setting a custom property is the proper way to do it.
That technique open up a world of possibilities once you've got it figured out.
I will however tell you why your session variable technique isnt working (and how to fix it).
The page has a life cycle of events that occur in a specific sequence.
You basic events are:
Based on your description, i would guess that you are setting up your usercontrol in the Load event. The Load event occurrs BEFORE any control events fire (such as datagrid clicks, button clicks etc..) So you are reading the session variable BEFORE it is
Whenever you are dependent on something that occurs as part of a control event firing, you must put that code AFTER the control events fire in your page's life cycle.
The short: Move your usercontrol setup code to the PreRender event.
Nov 04, 2005 07:49 AM|e106199|LINK
Nov 04, 2005 08:25 AM|e106199|LINK
Nov 04, 2005 09:06 AM|ashley.flynn|LINK
Nov 04, 2005 09:24 AM|booler|LINK
Nov 04, 2005 10:07 AM|e106199|LINK
Line 76: Private Sub btnSelect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSelect.ClickLine 77: Session("ReferralNo") = SearchGrid.RetrieveClientLastSelectedObject.KeyValueLine 78: myReferralInfo.GetReferralDetails()Line 79: End SubLine 80:
Nov 04, 2005 10:47 AM|ashley.flynn|LINK
there is sometimes a bug in VS that causes this but the most obvious thing to check is that in the HTML the user controls id attribute is EXACTLY the same as what you have called it in the cade behind
Nov 04, 2005 11:00 AM|mbanavige|LINK
Nov 04, 2005 11:03 AM|mbanavige|LINK
Nov 04, 2005 11:35 AM|e106199|LINK
Jan 03, 2007 12:29 PM|jrblack10|LINK
Ok, I have been suffering the same problem for quite some time now. I have read all the above posts. My UserControl is added at design time in HTML view.
HTML: <uc3:ucMessageDialog ID="UcMessageDialog" runat="server" />
I am able to access and set values in my UserControl:
The Page_Load of UcMessageDialog does nothing.
Instead I display a protected variable in the HTML: <%= _dynScript %>
_dynScript is set to initial value when declared in the code behind.
public partial class UserControls_ucMessage_Dialog : System.Web.UI.UserControl
public string _dynScript = "<!-- initial -->";
protected void Page_Load(object sender, EventArgs e)
I can step through all code including HTML and see that my changes are in deed being set (after page_load of UserControl) but the original value of _dynScript is displayed instead of the changed value of the.
In previous posts it was recommended to add something like this:
protected withevents usercontrol1 as myusercontrol
So I tried, but the word withevents gives me errors.
So I tried: protected UserControls_ucMessage_Dialog UcMessageDialog;
and got the following error:
Error 17 The type 'DB_Main' already contains a definition for 'UcMessageDialog' C:\Inetpub\wwwroot\....DB_Main.aspx.cs 33 45 http://localhost/
I am missing something... any other help?
Jan 04, 2007 12:04 PM|jrblack10|LINK