Click here to Skip to main content
16,017,986 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
VB
<%
dim fs
set fs=Server.CreateObject("Scripting.FileSystemObject")
if fs.FolderExists("D:\java\x.java.txt")=true then
  response.write("Folder c:\asp exists!")
else
  response.write("Folder c:\asp does not exist!")
end if
set fs=nothing
%>




I have a asp file with the following code , Now i want to read the value of response.write using javascript .
Posted
Comments
ZurdoDev 8-Oct-13 9:09am    
Response.Write will simply add the text to the output. JavaScript will have to scan the html to find it. You would be better setting a label.text value instead of using Response.Write so that the javascript can get the label value.

What exactly are you trying to do?
thatraja 8-Oct-13 9:15am    
This could be answer instead of comment.
Rayan Khan 8-Oct-13 9:19am    
I m trying to verufy that the folder in the directory exists or not.

Add a label or hidden field to your page then in C# set it's value. Then in JavaScript you can use document.getElementById() or jquery to get the value.
 
Share this answer
 
suppose name of this page is IsFoderExists.asp
VB
<![CDATA[<%
dim fs
set fs=Server.CreateObject("Scripting.FileSystemObject")
if fs.FolderExists("D:\java\x.java.txt")=true then
  response.write("Folder c:\asp exists!")
else
  response.write("Folder c:\asp does not exist!")
end if
set fs=nothing
%>


write javascript to call this page...
C#
function IsFolderExists()
    {
        if (window.XMLHttpRequest)
        {// code for IE7+, Firefox, Chrome, Opera, Safari
            xmlhttp1=new XMLHttpRequest();
        }
        else
        {// code for IE6, IE5
            xmlhttp1=new ActiveXObject("Microsoft.XMLHTTP");
        }
        xmlhttp1.onreadystatechange=function()
        {
            if (xmlhttp1.readyState==4 && xmlhttp1.status==200)
            {
                response.write(xmlhttp1.responseText);
// $('#div1').html(xmlhttp1.responseText); // you can display response in div.
            }
        }
        xmlhttp1.open("GET","IsFolderExists.asp",true);
        xmlhttp1.send();
        return false;
    }

Happy Coding!
:)
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900