I want to open a directory, that sits on a server, through a link.
My problem is that it works perfectly in an .htm page but not in an .asp page.
Here is what i use:
Foldername
I have tried using 3 or 5 slashes after the file: but the same result.
A different thing i found without result is:
Link
After trying to figure it out in html i tried the following in asp:
<%
str_url="file://server/folder/folder"
Response.Write("<script>")
Response.Write("window.open('" & str_url & "', 'myWin','height=800,width=1024,status=yes,toolbar=yes,menubar=yes,location=yes,resizable=yes,scrollbars=yes');")
Response.Write("</script>")
%>
But after several attempts to get stuff working i'm still banging my head against the wall. Could this perhaps be a disabled function in IIS7? Or am i missing something?
Thanks in advance
The file:// style links will only work for you on your local machine, you cannot open a folder on a remote server using that method. (well not unless that path is accessable from your local machine, a server share or somesuch)
Some sample code to display a directory:
<table cellspacing="0">
<tr>
<th style="width: 25px"> </th>
<th>Document</th>
<th style="width: 60px">Size</th>
</tr>
<%
Dim iCounter, iFileSize
Dim oFS, oFL
Dim sDirectory
sDirectory = "directory/you/want"
iCounter = 0
Set oFS = Server.CreateObject("Scripting.FileSystemObject")
Set oFL = oFS.GetFolder(Server.MapPath(sDirectory))
For Each oF In oFL.Files
iCounter = iCounter + 1
iFileSize = FormatNumber(CLng(oF.Size) / 1024 / 1024, 2)
%>
<tr>
<td><%=iCounter %>.</td>
<td><%=oF.Name %></td>
<td><%=iFileSize %> MiB</td>
</tr>
<%
Next
%>
</table>
Related
I've got some legacy websites that have been migrated to Windows Server 2019 and have found out that the code no longer seems to be functioning correctly. This is code for a simple poll/voting system. The problem that I'm currently running into is that when any of the links are clicked, it technically doesn't redirect from the page it's on. for example the PollList.aspx page (www.mysite/admin/PollList.aspx) has a few links on it. one of them is to load up the page PollEdit.aspx so a new poll can be added. the URL it's supposed to redirect to is www.mysite/admin/PollEdit.aspx?ID=0 (new poll only created by admins). however what it redirects to is: www.mysite/admin/PollList.aspx/PollEdit.aspx?ID=0 and stays on the current page.
Can someone show me what's broken? This was migrated from a Windows Server 2008r2 to Windows Server 2019. Let me know if there's any info needed.
below is the related content from the PollList.aspx page. everything else seems to be working just fine:
<form id="Form1" method="post" runat="server">
Edit Voter Permissions
<h1><center>Polls</center></h1>
<asp:repeater id="lstPolls" runat="server">
<HeaderTemplate>
<%= "<table border=0 cellpadding=0 cellspacing=4 align=center width=80% >" %>
<%= "<tr><td></td><td align=center><font size=2><a href=PollEdit.aspx?ID=0>[new poll]</a></font></td></tr>" %>
</HeaderTemplate>
<ItemTemplate>
<%="<tr bgcolor=#B3C9EF>"%>
<%# PrintPollItem(Container.DataItem)%>
<%= "</tr>" %>
</ItemTemplate>
<AlternatingItemTemplate>
<%= "<tr bgcolor=""#DFEBFF"">" %>
<%# PrintPollItem(Container.DataItem)%>
<%= "</tr>" %>
</AlternatingItemTemplate>
<FooterTemplate><%= "</table>" %></FooterTemplate>
</asp:repeater>
</form>
and below is the code behind content for the PrintPollItem() func:
Protected Function PrintPollItem(ByVal myPoll As BLL.Poll) As String
Dim txtTemp As New System.Text.StringBuilder
txtTemp.Append("<td>")
txtTemp.Append("<a href=PollEdit.aspx?ID=" & myPoll.ID.ToString() & ">")
txtTemp.Append(myPoll.Name)
txtTemp.Append("</a>")
txtTemp.Append("</td>")
txtTemp.Append("<td width=200 align=center>")
Select Case myPoll.OpenStatus
Case -1
txtTemp.Append("poll closed: <font size=2>[view results]</font>")
Case 1
txtTemp.Append("poll open: <font size=2>[view results]</font>")
Case Else
txtTemp.Append("poll pending: <a href=PollList.aspx?ID=" & myPoll.ID.ToString() & "&Action=open><font size=2>[open now]</font></a>")
End Select
txtTemp.Append("</td>")
Return txtTemp.ToString()
End Function
href you can give full path or relative path
you can use / or ../ or ~/ Before Assigning Link, That indicates current Files or Folder
Try href=/PollEdit.aspx
I am attempting to pass a parameter from one file to another via the URL after a button is clicked. These are written with Express.js (index.ejs to items.ejs).
As it stands currently I am setting the URL parameter in a defined Javascript function:
function loadItems(page, subcategory) {
window.history.pushState(null, null, "?subcat=" + subcategory) //param set
$('#mainContent').load(page);
}
where subcategory is the changing variable.
From there I am trying to read this parameter during an ASP.NET function written in embedded code blocks.
<% if(items[i].subcategory === Request.QueryString["subcat"].Value) { %> //get param
<% if (items[i].status === "Supported") { %>
<tr class="success">
<td>Edit</td>
<td id="item name"><%= items[i].name%></td>
<td id="subcat name"><%= items[i].subcategory%></td>
<td id="item status"><%= items[i].status%></td>
<td id="item desc"><%= items[i].description%></td>
</tr>
However I am met with an error which states Request is not defined and a callback to the above if statement. It is my understanding that on the ASP.NET side of things, Request.QueryString is a part of System.Web.HttpContext.Current.
How would I go about including this into my code blocks so that I am able to pull the parameter from the URL? Or, if this is not the way to be looking at this problem, how should I go about it?
My advice would be to use code behind. Embedded code blocks are an old-school throwback from the asp days. But if you must, then you should be able to do something like this:
<%# Page Language="VB" %>
<script run=server>
Protected Function GetSubcat() As String
Return Request.QueryString["subcat"].Value
End Function
</script>
<form id="form1" runat="server">
Subcat value is <% =GetSubcat()%>.
</form>
I want to export(force download) HTML(with CSS) to EXCEL sheet, for now I am using the PHPExcel library to perform this, it generate the excel file but remove the CSS (using inline with html tags), can anyone guide me, that how to keep CSS in excel sheet.
I am using this code, But I also want to keep the css and force to download
//html
$html = "<table>
<thead> <tr> <td colspan='2'> <h1> Main Heading </h1> <td> </tr> </thead>
<tbody>
<tr>
<th style='background:#ccc; color:red; font-size:15px'> Name <th>
<th style='background:#ccc; color:red; font-size:15px'> Class <th>
</tr>
<tr>
<td style='background:#fff; color:green; font-size:13px'> Jhon <th>
<td style='background:#fff; color:gree; font-size:13px'> 9th <th>
</tr>
</tbody>
</table>";
// Put the html into a temporary file
$tmpfile = time().'.html';
file_put_contents($tmpfile, $html);
// Read the contents of the file into PHPExcel Reader class
$reader = new PHPExcel_Reader_HTML;
$content = $reader->load($tmpfile);
// Pass to writer and output as needed
$objWriter = PHPExcel_IOFactory::createWriter($content, 'Excel2007');
$objWriter->save('excelfile.xlsx');
// Delete temporary file
unlink($tmpfile);
You can't read styles from HTML markup at the moment, unless you rewrite PHPExcel's HTML Reader to handle styles; it simply isn't supported yet. If you're building the spreadsheet from HTML, perhaps you should reconsider building it directly from a new PHPExcel object, which gives you access to all the features of PHPExcel.
To send to the browser, send to php://output with the appropriate headings, as shown in Examples/01simple-download-xlsx.php, and described in the section of the developer documentation entitled Redirect output to a client’s web browser
The following code displays as it is in browser instead of expected output. I have the table in sql server 2008. I have this code in webmatrix.
<%# Page Language="VB" %>
#{
var db = Database.Open("databasename"); 'database name in sql server is 'databasename'
var selectQueryString = "SELECT column_date, sum(qty1) as quantity1,
sum(qty2) as quantity2, sum(qty3) as quantity3
from tbldaily group by column_date order by column_date";
}
<!DOCTYPE html>
<html>
<body>
<h1>First table test</h1>
<table>
<tr>
<th>at_date</th>
<th>quantity1</th>
<th>quantity2</th>
<th>quantity3</th>
</tr>
#foreach(var row in db.Query(selectQueryString))
{
<tr>
<td>#row.column_date</td>
<td>#row.quantity1</td>
<td>#row.quantity2</td>
<td>#row.quantity3</td>
</tr>
}
</table>
</body>
</html>
I feel there is mistake somewhere in this code. Can you help me to fix this? Please let me know if you want more information regarding my database structure or table that may help to understand my scenario better
Looks like you are mixing Razor syntax with WebPages. Name your file *.cshtml and remove the first line which is for WebPages. The rest of your code is valid C# razor.
I think he needs the opposite of that. Keep it .aspx.
So wherever you have # tags to mark the asp code, use aspx escapes instead
<% For i As Integer = 0 To .... %>
<tr> <td> <%= row.column_date %> </td> ......
<% Next%>
I just want to show a result of a variable on a page and i am struggling
heres my code, the variable is in a table as you can see
thanks in advance
<tr><td><%
Dim sTest
sTest = "Monkey"
Response.Write("<p>" & sTest & "</p>")
%>
<p> This is Excel </p>
</td></tr>
Save the below code as HelloWorld.asp. Open this page in a web browser. Tell us what you see.
(Don't put any html code or anything else)
<%
Dim sTest
sTest = "Hello World"
Response.Write(sTest)
Response.End
%>
html code....
<p><%=sTest%></p>
html code....
I tried your code in a .asp file and it seems to be working... What problem are you facing? I have added border=1 to your code to show the table border...
<html> <body>
<%
Dim sTest
sTest= "TEXT"
response.write("<table border='1'><tr><td>")
response.write (sTest)
response.write ("</td></tr></table>")
%>
</body> </html>
I don't understant exactly your code (This is Excel? ,/tr>? ) but:
<%
Dim sTest
sTest= "TEXT"
response.write "<table><tr><td>"
response.write sTest
response.write "</td></tr></table>"
%>
Will write "TEXT" in the only cell of the table.
EDIT: He was using .htm as file extension.