Welcome Guest Search | Active Topics | Sign In | Register

Adding Control in Slide Options
Jaclyn
Posted: Wednesday, February 9, 2011 2:54:38 PM
Rank: Newbie
Groups: Member

Joined: 11/12/2010
Posts: 1
I am using a templated slide control. For each of the big items, I want to add a user control that I have created. I have added the control reference to the aspx page but cannot get the control to generate when the slide control is created.

I have tried creating a panel instead of the control and then putting the control on after the databind but that was not successful either.

Private Function CreateDataSource() As DataTable
Dim table As New DataTable()
table.Columns.Add("bigitem", GetType(String))
table.Columns.Add("thumbnail", GetType(String))
table.Columns.Add("title", GetType(String))
table.Columns.Add("summary", GetType(String))
table.Columns.Add("link_text", GetType(String))


table.Rows.Add("", "whatis_small.gif", "What is ?", "?????!")
table.Rows.Add("<uc1:LearnMore ID='uc1' runat='server' />", "learnmore_small.gif", "Learn more ", "????????????")
table.Rows.Add("", "gettingready_small.gif", "Getting ready ", "????????")
table.Rows.Add("", "needhelp_small.gif", "Need help ?", "?????????????")

Return table
End Function 'CreateDataSource

Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
Slide1.DataSource = CreateDataSource()
Slide1.DataBind()

End Sub 'Page_Load


<BigItemTemplate>
<div style="width:675px;height:300px;border:2px solid #000">
<%# Eval("bigitem")%>
</div>
<div>
<p style="font-family: Arial; font-size: 13px; color: #000">
<h3><%#Eval("summary")%></h3>
</p>
</div>
</BigItemTemplate>
eo_support
Posted: Wednesday, February 9, 2011 3:09:25 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

No. You can not add user control that way. ASP.NET generates the final output based on your definition and code. You are literally adding string "<uc1:LearnMore ID='uc1' runat='server' />" to the final output through code. This literal string "<uc1:LearnMore ID='uc1' runat='server' />" is not being interpreted by ASP.NET thus will not render as a user control as you expected. It will be rendered exactly as you type it in the final HTML output.

The most straight forward way for your situation is to put "<uc1:LearnMore ID='uc1' runat='server' />" directly inside your BigItemTemplate in your .aspx file, that way ASP.NET will interpret it and translate it into whatever your LearnMore user control renders. If you want to enclose it in a table, you would also put the corresponding raw HTML markup such as "<table">, "<td>" or whatever in there. It is possible to dynamically create user control in code, but you would have to dynamically create the user control directly. For example, you can call “new YourUserControlTye()” and then add it to another container. There are also special consideration about events when do so. It's usually more difficult that way.

Hope this helps. If you still have problem, you may want to ask someone around you for help. Your question is really about how to dynamically add a control into a template. We consider this a very generic ASP.NET programming question. While our support don't mind to point you to the right direction in such cases, our work focus exclusively on our product so we do not offer tech support for generic programming questions.

Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.