Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. binding xml file with dropdownlist

binding xml file with dropdownlist

Scheduled Pinned Locked Moved ASP.NET
wpfwcfxmltutorial
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sonyrehal
    wrote on last edited by
    #1

    plz tell me how to populate a dropdown list with this xml file: countries in one dropdown,,and states in 2nd dropdown 1 2 3 4

    R 1 Reply Last reply
    0
    • S sonyrehal

      plz tell me how to populate a dropdown list with this xml file: countries in one dropdown,,and states in 2nd dropdown 1 2 3 4

      R Offline
      R Offline
      rakeshs312
      wrote on last edited by
      #2

      sorry, use this file aspx

      <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

      <html xmlns="http://www.w3.org/1999/xhtml" >
      <head runat="server">
      <title>Untitled Page</title>
      </head>
      <body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080"
      alink="#ff0000" onload="parseXML()" >

      <FORM name="drop_list" method="POST" >

      <SELECT NAME="Month_list">
      <Option value="" >Month list</option>
      </SELECT>
      </form>

      </body>

      </html>

      <script language="javascript" type="text/javascript">

      function parseXML()
      {

      try //Internet Explorer
      {

      xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
      }
      catch(e)
      {
      try //Firefox, Mozilla, Opera, etc.
      {

      xmlDoc=document.implementation.createDocument("","",null);
      }
      

      catch(e)
      {
      alert(e.message);
      return;
      }
      }
      xmlDoc.async=false;
      xmlDoc.load("XMLFile1.xml");
      var markers = xmlDoc.getElementsByTagName("marker");
      //alert(markers.length);
      for (var i = 0; i < markers.length; i++) {
      // obtain the attribues of each marker
      var label = markers[i].getAttribute("label");
      //alert(label);
      var area = markers[i].getAttribute("area");
      if(label!=null)
      {
      addOption(document.drop_list.Month_list, label, area);
      }

      }

      function addOption(selectbox,text,value )
      {
      var optn = document.createElement("OPTION");
      optn.text = text;
      optn.value = value;
      selectbox.options.add(optn);
      }

      }
      </script>

      XML

      <?xml version="1.0" encoding="utf-8"?>
      <marker>
      <marker area="Melbourne1" label="burwood" />
      <marker area="Melbourne4" label="cumming st" />
      <marker area="Melbourne6" label="illard" />
      </marker>

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups