[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.aspnet.mobile

getting started...dynamic controls

Eric Pearson

6/7/2002 10:01:00 PM

I'm getting started on mobile forms.

I'd like to output one link (a servercontrol so it can render it any way it
needs to) for every element in an array

Do I approach this using <% for.....%>

????


1 Answer

(Joseph Croney (MSFT))

6/8/2002 12:30:00 AM

0

Hi Eric,
Here is a sample which runs through a string array and dynamically creates
mobile:link controls.

<script runat="server" language="c#">
private void Page_Load(object sender, System.EventArgs e)
{
// Array of Links
string[] LinksArray = new string[]
{"FirstLink.aspx","SecondLink.aspx"};

// Go through the array, dynamically create link controls
// and add them to the panel
foreach (string s in LinksArray)
{
Link myLink = new Link();
myLink.NavigateUrl = s;
myLink.Text = s;
Panel1.Controls.Add(myLink);
}
}
</script>

<mobile:Form id="Form1" runat="server">
<Mobile:Panel id="Panel1" runat="server"></Mobile:Panel>
</mobile:Form>



Hope this helps,
Joseph Croney

-----------------------------------
This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. © 2002 Microsoft Corporation. All rights
reserved.