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?

2
  • What is "with an tag insert in between each line" supposed to mean.....? What tags.....? Commented Jul 9, 2014 at 15:12
  • apologies i mean anchor tags for hyperlinks Commented Jul 9, 2014 at 15:13

2 Answers 2

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);
Sign up to request clarification or add additional context in comments.

Comments

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(...)

4 Comments

Did you try this first? InputAttributesseems to be a CheckBox-only property.
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.
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....).
ListItems does have a Attributes as can be seen here. So by giving the listitems identities it would be possible to manipulate the attributes for them as well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.