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

Dynamic RadPageView passing a variable

4 Answers 73 Views
ToolBar
This is a migrated thread and some comments may be shown as answers.
Moon
Top achievements
Rank 2
Moon asked on 03 Nov 2008, 05:00 PM
You have provided an example of how to create a dynamic RadPageView, loading a dynamic user control.
http://demos.telerik.com/aspnet/prometheus/TabStrip/Examples/ApplicationScenarios/DynamicPageView/DefaultCS.aspx

How does one then pass a variable value into this dynamic user control?

Your example doesn't show that.

thanks.

Moon.

4 Answers, 1 is accepted

Sort by
0
Blaize
Top achievements
Rank 1
answered on 03 Nov 2008, 05:12 PM
Hey Moon,

what about

((MyUserControlType)multiPage.Controls[0]).MySpecificStringProperty = "Something"; ?

or

((Label)multiPage.Controls[0].FindControl("MyLabel1")).Text = "Something"; ?

Cheers,
Blaize
0
Moon
Top achievements
Rank 2
answered on 03 Nov 2008, 05:48 PM
Sorry, that confuses me.

I use this in the PageViewCreated function:

        Dim userControlName As String = String.Empty
        userControlName = "~/Modules/Login/Controls/RegisterControl.ascx"
        Dim uc As Control = Page.LoadControl(userControlName)
        uc.ID = "pvRegister" & e.PageView.ID
        e.PageView.Controls.Add(uc)

At this point, my control ID will be "pvRegisterForum" perhaps.

My control name is: RegisterControl.ascx

I want to call this function, SetuserType, within my control:

Select Case e.PageView.ID
            Case Enums.UserType.Forums.ToString
                myControl.SetUserType(Enums.UserType.Forums)

How do I get the "myControl" value?
How do I find this control and use it to call the SetUserType function?

thanks.
0
Moon
Top achievements
Rank 2
answered on 03 Nov 2008, 05:52 PM
BTW, I'm not certain the type to cast it to...

I've tried this:

        Dim myControl = DirectCast(RadMultiPage1.Controls(0).FindControl(uc.ID), RadPageView)
        myControl.SetUserType(Enums.UserType.Forums)

But it says SetUserType is not a member of RadPageView.

I'm really lost on this. Sorry.
0
Blaize
Top achievements
Rank 1
answered on 03 Nov 2008, 10:11 PM
Hey Moon,

You should use the following (assuming you use a web application project, but not a website):

Dim myControl = DirectCast(RadMultiPage1.Controls(0).FindControl(uc.ID), [MyUserControlTypeName])
        myControl.SetUserType(Enums.UserType.Forums)


I assume the user control has the SetUserType method already.

If having a web site, the things get a bit trickier:
You should create a base class (e.g. MyUserControlBase), deriving from UserControl to the App_Code folder. The base class should contain the SetUserType method in it. Then you should just modify your user control to inherit the MyUserControlBase class.

Cheers,
Blaize
Tags
ToolBar
Asked by
Moon
Top achievements
Rank 2
Answers by
Blaize
Top achievements
Rank 1
Moon
Top achievements
Rank 2
Share this question
or