This is a migrated thread and some comments may be shown as answers.

Accessing controls within a LoginView in the advanced form.

1 Answer 85 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Jill-Connie Lorentsen
Top achievements
Rank 1
Jill-Connie Lorentsen asked on 01 Nov 2012, 12:17 PM

I have a RadScheduler where I use the AdvancedInsertTemplate and AdvancedEditTemplate.

In the AdvancedForm user control I want to show different controls depending on the logged in user is Administrator or a normal user. So I've added a LoginView like this:

<asp:Panel runat="server" ID="AdvancedControlsPanel" CssClass="rsAdvMoreControls">                  
<asp:Panel runat="server">
<%-- RESOURCE CONTROLS --%> 
<ul class="rsResourceControls">
<li>
<asp:LoginView ID="LoginView1" runat="server">
<RoleGroups>
<asp:RoleGroup Roles="Administrator">
<ContentTemplate>
                                              
<!-- Resource controls should follow the convention Res[Resource Name] for ID -->
 <scheduler:ResourceControl runat="server" ID="ResCustomer" Type="Customer" Label="Customer: "
Skin='<%# Owner.Skin %>' />
                                                          
 <telerik:RadComboBox runat="server" ID="EmployeeComboBox" Label="Employee: " Visible="true"
Skin="Outlook" Width="300px" CausesValidation="false" OnClientSelectedIndexChanged="OnClientSelectedIndexChanged"
OnClientLoad="employeeClientLoad">
</telerik:RadComboBox>
                                              
</ContentTemplate>
</asp:RoleGroup>
<asp:RoleGroup Roles="User">
<ContentTemplate>
<asp:Label ID="LabelCustomer" runat="server" Text="CustomerName" />
</ContentTemplate>
</asp:RoleGroup>
</RoleGroups>
</asp:LoginView>
  
...

When compiling I then get an error saying "ResCustomer does not exist in current context":

[Bindable(BindableSupport.Yes, BindingDirection.TwoWay)]
        public object Customer
        {
            get
            {
                return ResCustomer.Value;
            }
  
            set
            {
                ResCustomer.Value = value;
            }
        }

I then try to access the controls within the LoginView, but I can't find them:

LoginView lv = FindControl("LoginView1") as LoginView;
RadComboBox employeeComboBox = lv.FindControl("EmployeeComboBox") as RadComboBox;
Label customerLabel = lv.FindControl("LabelCustomer") as Label;

But now both the employeeComboBox and the customerLabel are null? The LoginView1 has been found, though.

And how do I find the ResCustomer?

On the page where the RadScheduler is I have a similar scenario, and there the controls within the LoginView are found without any problem.

What am I missing?

Regards, Jill-Connie Lorentsen

1 Answer, 1 is accepted

Sort by
0
Plamen
Telerik team
answered on 06 Nov 2012, 01:46 PM
Hello Jill,

The issue seems like an issue that in LoginView itself that is why I would recommend you to refer to some more appropriate ASP.Net forum where this issue have been discussed like these ones:
http://forums.asp.net/t/1355110.aspx/1
http://weblogs.asp.net/sukumarraju/archive/2011/01/31/find-control-with-in-loginview-control.aspx

Once you are able to find the objects you can replace the instances accordingly in the code behind of the advanced form.

Hope this will be helpful.


Greetings,
Plamen
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Scheduler
Asked by
Jill-Connie Lorentsen
Top achievements
Rank 1
Answers by
Plamen
Telerik team
Share this question
or