When you set the value of a user control in a master page, do you have to
reference it differently? Also, do they have to be given different names in
the templates?
For example, this is what I have....
(uc1 is a user control I defined)
MasterPage.master
-- FormView#FormView1
--<EditItemTemplate>
--<table><tr><td>
-- uc1:ucTimeSelect ID="ucTime1"
--<ItemTemplate>
--<table><tr><td>
-- uc1:ucTimeSelect ID="ucTime1"
--<InsertItemTemplate>
--<table><tr><td>
-- uc1:ucTimeSelect ID="ucTime1"
Note that all the user controls have the same name.
In my code, when I switch modes in my formview I am trying to call a
function SetTime in my uc. It seems to work because I check the value
before & after. But it doesn't visually appear on the screen. Here's the
different ways I have tried...
1. CType(FormView1.FindControl("ucTime1"),
common_ucTimeSelect).SetTime(MyTime)
2.
CType(FormView1.Controls(0).Controls(1).Controls(0).FindControl("ucTime1"),
common_ucTimeSelect).SetTime(MyTime)
I check the value of the user control and the time IS set correctly, but
it's doesn't appear set on the screen.
Can you help me out?
Thanks!
Juan T. Llibre - 19 May 2008 14:17 GMT
To add a web user control to a master page, you must register the control
<%@ Register TagPrefix="uc1" TagName="ucTimeSelect" Src="~/ucTimeSelect.ascx" %>
-- FormView#FormView1
--<EditItemTemplate>
--<table><tr><td>
<uic1:ucTimeSelect id="ucTime1" runat="server" />
etc...
Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
> When you set the value of a user control in a master page, do you have to reference it differently? Also, do they
> have to be given different names in the templates?
[quoted text clipped - 28 lines]
>
> Thanks!
Cirene - 19 May 2008 15:45 GMT
I didn't want to add the uc to a master page. I wanted to add it to a page
that is based on the master page.
And, I did add the register at the top of the page already. :)
It shows up fine. It's just that when some values are set (via code) it
looks like it took (when debugging) but when the page shows up it doesn't
reflect the changes.
> To add a web user control to a master page, you must register the control
>
[quoted text clipped - 49 lines]
>>
>> Thanks!
Cowboy (Gregory A. Beamer) - 19 May 2008 15:29 GMT
To follow up on Juan's post, the reason user controls are tricky in a master
page is the master page is, underneath the hood, a user control. I know it
does not feel this way when you design with it, but it is.

Signature
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA
Subscribe to my blog
http://gregorybeamer.spaces.live.com/lists/feed.rss
or just read it:
http://gregorybeamer.spaces.live.com/
*************************************************
| Think outside the box!
*************************************************
> When you set the value of a user control in a master page, do you have to
> reference it differently? Also, do they have to be given different names
[quoted text clipped - 34 lines]
>
> Thanks!