Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create Clientside list from dataview?

Status
Not open for further replies.

chrigil

Programmer
Sep 23, 2003
178
GB
Can anyone give me some advice on creating a clientside JavaScript list from an ASP.Net filtered Dataview?

I have a dataset with 2 tables, one for the navigation MainMenuItems and another for the SubMenuItems relating to those MainMenuItems.

I am using a Repeater to bind the MainMenuItems to make a navigation system but when it comes to the SubMenuItems I can only bind them with a page reload. I want to be able to view the SubMenuItems on rolling over the MainMenuItems.

My idea is to sort the SubMenuItems into a ClientSide JavaScript list which I can then access using JavaScript from within my page.

How would I do this?


Thanks in advance,

Chris
 
Hi,

One way would be to user GetXml() and have a server side variable (xmlString) hold the XML string. xmlString would need to be declared with an access modifier of protected. This way it can be accessed in the web page that inherits from the code behind as
var xmlStr;
xmlStr = "<%=xmlString%>"
(kinda sorta like creating a data island)

You can now load it into the DOM and execute client side code that will use XPath to query the data for selections in the independent dropdown.

HTH

amit
 
Hi,

One way would be to user GetXml() and have a server side variable (xmlString) hold the XML string. xmlString would need to be declared with an access modifier of protected. This way it can be accessed in the web page that inherits from the code behind as
var xmlStr;
xmlStr = "<%=xmlString%>"
(kinda sorta like creating a data island)
Alternaltely, u cud response.write javascript arrays, i wud recommend the getXml and DOM approach.

You can now load it into the DOM and execute client side code that will use XPath to query the data for selections in the independent dropdown.

you will also probably want to maintain state which will have to be done manually.

one last thing - u cud also look into using HTML server controls, that shud give u client side convenience and not have to manually maintain state.

HTH

amit
 
Ok so not knowing much about XPath etc i could do with a bit more advice.

It sounds perfect for what I want but i need a few questions answering.

1) How would I get an XML formatted result from my DataSet?

2) How would I load it into a clientside DOM. Would I use JavaScript?

3) Once in the DOM do I use JavaScript to make use of XPath?

4) If I loaded all the submenu data into an XML document stored in memory somehow would I be able to filter the results using JavaScript and XPath? For example could I make it so that when I rollover the link for HOME the JavaScript/XPath filters the SubMenu data by one of the XML elements? Thus allowing me to display the submenus relating to HOME without reloading the page?



Thanks in advance,

Chris
 
For number 1 you should have a look at some of the properties for a DataSet. You will notice that there is a WriteXml property.

----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
Also, you may want to have a look at skmmenu ( as this is a free menu component which will automatically create the necessary JavaScript menu which supports submenu's.

----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top