Friday, 15 February 2013

c# - ASP.NET Generated Output Not Effected By JQuery/Javascript -



c# - ASP.NET Generated Output Not Effected By JQuery/Javascript -

i have below code dynamically generates directory tree in html list format. when seek manipulate list items javascript add together '+' end of item, doesn't work. know jquery correct, have used on page on same server. jquery not able manipulate info dynamically generated server side asp.net?

<script langauge="c#" runat="server"> string output; protected void page_load(object sender, eventargs e) { getdirectorytree(request.querystring["path"]); itemwrapper.innerhtml = output; } private void getdirectorytree(string dirpath) { seek { system.io.directoryinfo rootdirectory = new system.io.directoryinfo(dirpath); foreach (system.io.directoryinfo subdirectory in rootdirectory.getdirectories()) { output = output + "<ul><li>" + subdirectory.name + "</li>"; getdirectorytree(subdirectory.fullname); if (subdirectory.getfiles().length != 0) { output = output + "<ul>"; foreach (system.io.fileinfo file in subdirectory.getfiles()) { output = output + "<li><a href='" + file.fullname + "'>" + file.name + "</a></li>"; } } output = output + "</ul>"; } } grab (system.unauthroizedaccessexception) { //this throws when don't have access, nil , move one. } } </script>

i seek manipulate output following:

<script langauge="javascript"> $('li > ul').not('li > ul > li > ul').prev().append('+'); </script>

just fyi code div below:

<div id="itemwrapper" runat="server"> </div>

it looks have couple of problems here. first should set jquery code within of $(document).ready. ensures dom has loaded before seek mess it. secondly, selector looking ul elements direct children of li elements. code not generate such html. have li's within of ul's not other way around. also, if directory has files in it, going leave ul elements unclosed mess html , javascript.

c# jquery asp.net css

No comments:

Post a Comment