I've created a pseudo user control for a site written in classic asp. The control is simply an asp page (with full HTML headers and body) that resides within an iframe in the parent page. The point was to create an AJAX-like interface for uploading files asynchronously (the parent page contains a large form and I didn't want to have to upload the files and submit the rest of the form at the same time).
The problem is, I'm running into a lot of issues with relative urls being used in the iframe page/user control. Depending on what page the iframe is a child of, the relative url base location seems to change according to the directory that particular page is in.
Example:
www.website.com/directory1/application1.asp
...
<form>
<input>
...
<iframe src="../controls/FileUpload.asp"/>
...
</form>
...
www.website.com/directory1/directory2/application2.asp
...
<form>
<input>
...
<iframe src="../../controls/FileUpload.asp"/>
...
</form>
...
www.website.com/controls/FileUpload.asp
...
<form method="post" enctype="multipart/form-data" action="FileUpload.asp"><!--problem here-->
<input type="file">
<input type="submit"/>
</form>
The iframe src paths work correctly (notice the one that's buried a directory deeper has an extra double dot). But in the code for the FileUpload.asp page, relative URLs don't work consistently. The URL I have in the action attribute for the form tag works if you simply load the page as-is, not in an iframe of another page. You can change it to "../controls/FileUpload.asp" and it will work on the first application page, but you have to add another "../" for it to work on the second application page.
I was wondering if maybe there's a way with vbscript to find the absolute URL to a certain file. I do use an include file into which I could hard-code this, but I'd rather not if that's possible. Any other ideas?
You could also just put in an absolute path from the root such as
action="/controls/FileUpload.asp"
I'm not sure if you are perhaps looking for
<%
Response.Write Server.MapPath("./foo.txt")
%>
Some usefull code from Thorarin
that I just saw in a different post
Look for ThisPage() Function
Related
I am trying to set up a global search box that posts to a search page in umbraco 7. This template uses a shared partial containing Html.BeginUmbracoForm() that points to a SurfaceController.
Since this is a global control, I want the form to be posted to the /search page instead of the current page. BeginUmbracoForm only seems to be able to post to the current page unless I'm mistaken.
I want something like RedirectToUmbracoPage(id), but clears this post values on redirect.
Is there a way to get an ActionResult like CurrentUmbracoPage which keeps the post values?
I would not try using surfacecontrollers for that purpose. Surfacecontrollers are auto routed. They are created to (e.g.) make #Html.Action(...) work on every umbraco page. Including postbacks on these actions or macros.
If you only need a "redirect" to the /search page, you don't need a surface controller. A simple partial will do the job.
<form action="/search" method="get">
Search <input type="search" name="q" />
</form>
Of course you can replace the url using some Umbraco logic like #Umbraco.TypedContentSingleAtXPath("//Search") or other Umbraco magic.
In the umbraco documentation project is an example where Html.Action is used.
Please note I'm not interested in a Polymer-, Angular- or route-based solution here. I'm trying to learn "pure" Dart here, and while I'll likely switch to using one of those frameworks down the road, I need to have a good understanding of the fundamentals first.
In Dart, is it possible to download a whole bunch of HTML "snippets" (see below) all at once (at app startup), and then load them into the browser (either the entire window or just inside a particular <div> element, etc.) dynamically?
For instance, my HTML file might have a <div> element:
<body>
<!-- lots of HTML -->
<div id="container"></div>
<!-- more HTML -->
</body>
And I would like to download two "snippets" (DOM subtrees, HTML templates) of HTML, and dynamically load either one of them into the container div tag. Perhaps one of the snippets looks like this:
<h1>I'm Snippet #1!!!</h1>
<input type="button" name="redPillButton" value="Red Pill!" />
And another snippet my look like:
<h1>I'm Snippet #2!!!</h1>
<input type="button" name="bluePillButton" value="Blue Pill!" />
Can the two snippets be inside their own HTML file, or do I have to put them inside one big file and extract out the "snippet" that I want to load? Either way, how do I accomplish this in a Dart web app?
You can keep each parts in their own file and load them like that :
HttpRequest.getString("part.html").then((html) {
querySelector('#container').innerHtml = html;
});
This should be pretty simple but I am having an issue.
I have a sidebar that is included into every page we have in our website. Now those pages can sometimes be found in different folders, so that poses an issue. When you are on index.php and fill out the form on the page, it directs you to the correct path.. But if you are in, (fictional folder title for clarity,) password/index.html that sidebar cannot link to the proper file to send the user upon form completion.
Here is my code:
form name="sms_signup" method="post" action="text_alerts_thank_you.html" onSubmit="return ValidateForm();" target="_self" style="padding-bottom:25px;" class="form-horizontal">
What I need to know is, how do I tell HTML o go to the root of the directory and then access the file?
Thanks!
Start the action with a "/":
<form name="sms_signup" method="post" action="/text_alerts_thank_you.html" onSubmit="return ValidateForm();" target="_self" style="padding-bottom:25px;" class="form-horizontal">
You may have to look at displaying the path correctly within the "action" input.
See this question for more information on paths. HTML - pick images of Root Folder from Sub-Folder
I am having trouble with only firefox. My page shows a tree structure that is loaded via ajax as the user clicks on the nodes they want to expand. The problem I'm having with firefox, and only firefox, is that it will expand the nodes on the first page load. But after that firefox caches it weird and the node header, not children, of the ajax request gets carried over to the new page. This is an issue because the node's header that is carried over contains information that determines if the node has retrieved it's children.
<div class="node topbar"
<input type="hidden" id="foo" name="hasretrievedchildren" value="1"/>
...
</div>
It should be as it is on the first page load.
<div class="node topbar"
<input type="hidden" id="foo" name="hasretrievedchildren" value="0"/>
...
</div>
My Javascript checks for a nonzero value on that input to do the AJAX call.
Is this a bfcache issue?
I'm lead to believe it's not because I added
window.onunload = function();
to the js file and in a script tag and neither fixed it which this article
https://developer.mozilla.org/en-US/docs/Using_Firefox_1.5_caching
says should invalidate the bfcache.
I'm using asp.net MVC 4 and I tried using the MVCdonutcaching to set this page and partial views to not cache. But that didn't work either.
Maybe it's the bfcache, maybe it's not.
I had to face the same problem some time ago. The browser caches were causing some strange behaviour on our forms, and it was affecting the expected results of the page.
Someway to solve itSomething you can do in order to make the program load always the correct value (assuming you are loading it from ) is to initialize the value through your Javascript.
If you use JQuery, you should use:
<script type="text/javascript">
$(document).ready(){
//Assign your items values here
}
<script>
You can also use the onload handler in JS.
Hope this helps.
I was able to solve the problem. Firefox caches all form data even hidden inputs. Since I was using a hidden field to store the flag that enabled the AJAX request it would reload the form data with the flag set. I moved it to a custom attribute and it works exactly as it should.
I've got an ASPX page rendering a search ascx page which in turn will fill a grid on the main ASPX page.
Aside that, I've also got an ascx page which uploads files, like this:
<form method="post" action="<%= Url.Action("UploadFile") %>" enctype="multipart/form-data">
<fieldset>
<input type="file" name="file" id="file" />
<%=Html.ButtonSubmit("Upload") %>
</fieldset></form>
Here's the problem: imagine I have searched for a single entry to be displayed on the grid. The grid displays this single entry and after wards, I upload a file and press the button "Upload". The whole page gets posted and the content in the grid is lost, now displaying all the results available.
What could I do to prevent this from happening, maintaining the grid state (we're not using ViewState) or otherwise not posting back the whole page but only the ascx with the file upload?
Note: I'm new to MVC.
Your partial view is rendered inside your HTML... this results in a single "static" HTML-file without the option to submit and reload only parts of it.
I can imagine two ways to solve your problem:
1) Place your upload-formular inside an HTML-iFrame... now only this iFrame will reload on submit. Problem: Communication between parent and child-frame to have the uploaded data available, depending on what kind of action you would like to have after uploading.
2) Use jQuery/AJAX to make a javascript-based submit (http://api.jquery.com/jQuery.post/) and refresh your page content dynamically with jQuery/JavaScript. This would be my prefered way but needs some more knowledge about jQuery/JavaScript.
BTW: jQuery is nearly a must-have for any asp.net mvc application ;-)
Welcome to MVC :-)