Deleting a directory when clicked on a hyperlink with JAvascript.ASP.NET C#

坚强是说给别人听的谎言 提交于 2019-12-02 18:06:50

问题


This isn't working:

 Response.Write("<a href=view.aspx?type="+Content+"onclick=\"Delete('"+f+"')\"> DELETE </a>");


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

        function Delete(path) {
        path1 = unescape(path);
        var myObject = new ActiveXObject("Scripting.FileSystemObject");
        var myFolder = myObject.GetFolder(path1);

        myFolder.Delete();

        alert("Welcome");
    }
 </script>

But this worked.

  Response.Write("<a href=view.aspx?type="+Content+"onclick=\"Delete()\"> DELETE </a>");

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

        function Delete() {

        alert("Welcome");
    }
 </script>

I tried with onclick for Delete() to get just ALERT it worked well. But it isn't working when add the parameters.Can you help me please.Trying for this from long time please.


回答1:


First of all, \u is escpae code for a hex digit. So better re-format it.

Second, href=view.aspx?type=notes is not a valid html syntax too. Double quotes please.

Third, please put some code to check if your javascript variables (myObject,myFolder) are valid (not null) before invoke any method against them.



来源:https://stackoverflow.com/questions/6436192/deleting-a-directory-when-clicked-on-a-hyperlink-with-javascript-asp-net-c-sharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!