0

I am using the html list to help find specific areas on a map using leaflet. This is a normal html ul list but with an tag insert in between each line. I have also included the data-position and zoom attributes to pin-point a specific location on the map.

HTML list:

<ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1">
    <li role="presentation"><a href="#" data-zoom="6" data-position="57.3666,   -25.0008"> Orginal map.....</a></li>
    <li role="presentation"><a href="#" data-zoom="12" data-position="54.3666,-9.0"> Irish Continental Shelf</a></li>
    <li role="presentation"><a href="#" data-zoom="12" data-position="53.27,-9.91"> Irish Exclusive Economic Zone</a></li>
    <li role="presentation"><a href="#" data-zoom="12" data-position="51.74404,-10.12931"> Irish Territorial Sea</a></li>
    <li role="presentation"><a href="#" data-zoom="12" data-position="53.35547,-6.17153"> Irish Contiguous Zone</a></li>
</ul>

ASP DropDownList:

<asp:DropDownList ID="DropDownList1" runat="server" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged" AutoPostBack="true" BackColor="BurlyWood">  
    <asp:ListItem  Value="Navigation ToolBox Control">Irish Continental Shelf</asp:ListItem>  
    <asp:ListItem Value="Standard ToolBox Control">Irish Exclusive Economic Zone</asp:ListItem>  
    <asp:ListItem Value="Data ToolBox Control"> Irish Territorial Sea</asp:ListItem>  
    <asp:ListItem Value="Login ToolBox Control">Irish Contiguous Zone</asp:ListItem>  
</asp:DropDownList>

Now i want to use a asp:Dropdown list but c# sharp dose not allow any tags. This means I can not link to a specific point on the map using data-postion or zoom.

Is there a way in C# to incorporate this feature?

Austin Mullins
  • 7,307
  • 2
  • 33
  • 48

2 Answers2

1

you can use something like this

ListItem a1 = new ListItem("Irish Continental Shelf");
        a1.Attributes["data-position"] ="12,54";
        a1.Attributes["test2"] = "2";
        DropDownList1.Items.Add(a1);
0

As far as I can tell, you're really interested in the Attributes of the listitems. In that case, according to this QnA you should use the InputAttributes property.

myDropDownList.InputAttributes.Add(...)
myListItem.InputAttributes.Add(...)
Community
  • 1
  • 1
fredrik
  • 6,483
  • 3
  • 35
  • 45
  • Did you try this first? `InputAttributes`seems to be a CheckBox-only property. – JW Lim Jul 09 '14 at 15:19
  • Unfortunantly no, don't have a compiler or a project handy at the moment. Seems that the property is normally named `Attributes` on ASP.NET controls. – fredrik Jul 09 '14 at 15:45
  • Well, I did try it, and neither the DropDownList nor ListItem class has `InputAttributes`. `Attributes` only refers to the attributes to the control itself, inside the opening tag, like `id="foo"` or `style="foo"`. So `Attributes` isn't correct either. And since ListItem doesn't seem to have the `Controls` property either, I'm not sure what would work (there *should* be a way, though....). – JW Lim Jul 09 '14 at 15:49
  • `ListItems` does have a `Attributes` as can be seen [here](http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.listitem.attributes(v=vs.110).aspx). So by giving the listitems identities it would be possible to manipulate the attributes for them as well. – fredrik Jul 09 '14 at 17:42