First I am new to the asp .net world and am trying to figure out a weird issue that I am having. Any suggestions or comments are welcome.
I have a page that has a form and on submit I launch another aspx file that exists in the same directory.
The problem is the aspx file is shown and the file closes immediately!.
Howewever, the weird part is if I make any modifications to the aspx file and save it and then run my application it works fine ONLY THE FIRST TIME!? any subsequent submit actions launch the aspx page but then the aspx file immediately closes.
But after I make some modifications to the aspx file..(simple ones) it launches correctly the first time.
I realize that this is very little info to go on and I am not even sure if I have got my point across...but any suggestions on how to debug this will be helpful.
We are targetting .net version 4.0 and using IIS7.
I am thinking that the asp worker process is doing something weird like checking for timestamps and closing it?! Not sure tho.
Any help is appreciated.
ASP.Net webforms don't use the form in quite the same way as regular HTML forms. All you need in your form tag is
<form runat="server">
If you want to pass the user onto another aspx page you can use the Response object:
Response.Redirect("~/pages/SomeOtherPage.aspx");
or (Server.Transfer - read up on the differences)
Server.Transfer("~/pages/SomeOtherPage.aspx");
If you want to open a page in a new/pop-up window or similar you'll need to do so using JavaScript
window.open('/pages/SomeOtherPage.aspx') [There are overridden versions of this method]
You can use the forms PostbackUrl property too, but this will also keep the user in the same browser window. More info here.
HTH
Related
We provide live chat service to our customers. customer just copy some code and put in their footer. then they can have video chat, cobrowsing and many things..
but problem comes when user switch from page to page. so we have resume functionality as well. but thats not robost solution.
So i've come to two solution.
1. Iframe solution
i'll give client a some.html file which he'll need to upload to their root url, then upon video chat and cobrowse we load that page in some.html's iframe and chat appear in some.html
so that work well. chat box apprear seamlessly no page reload effects came in. and as its on same domain i can access all contents of iframe.
2. Another hack solution (not implemented yet, looks good solution)
i was thinking that instead of redirecting user to new page (some.html)
i should clear all contents of current page and load same url in one iframe within the page.
i think that will work well. but i affraid that some client might be using complex js based web app. so if i remove complete body from their page they might have problems.
as much as i know i can remove all dom nodes with their events handlers as well. but is their way to clean js runtime. so all js objects will destroyed and removed from scope so no longer run.
so is there a ways to clear any page completely with all its html and associated java-script as well. means reset page to blank.
Finally i found that there is no way to reset page.. but got another way to make it done.
upon need we can redirect user to same page with query string that identity that its reload for iframe, we put small bit of another code at head which remove all dom before loading dom, css, js.. and create just one iframe of same url.
thus it allows me, have user see no change in url, user browse website as normal without any problem and my chatbox always be there in same state across all pages.
will make it live soon on tagove.com
Why don't you empty the HTML page using empty() function of jquery first,
Then remove/update the link i.e.<script src="...."></script> so that the HTML has no dependency on that javascript and that way it won't be able to Modify the DOM.
And then try to build a javascript program to remove any file in the folder which is isolated(No calling, No dependency, no connection whatsoever)
I was doing a rails project and I added a small piece of 3rd party javascript which generated a button to my html.erb file in view, then I deleted it. However, the javascript (of course the button) keeps loading even if the source code didn't have that block. And more, whenever I created a controller/action, when I visit the page, the button will show up. Could anyone help me with that?
It's hard to help without seeing the code/error.
But I would recommend either:
Removing the javascript gem.
Searching and deleting the javascript.
So I have a somewhat unique issue I believe and I'm not sure what's the best way around it. I have some legacy code that has worked fine in the past in all browser's and suddenly in IE10 it is not working. I'll try to explain as best I can how it works and what I think is the issue.
I am working on an online banking page which has an option for the user to download their account history as a QIF, CSV, etc. The page is written with Classic ASP and VB server code. The way the feature works is the user clicks the download button which reloads the page with a series of clickable images, one for each download file type. Based on the one they click, a javascript function is then called which submits a hidden form on the page and then submits a second hidden form in order to reload the original view with the account history and filters again. The first form action calls an asp page which builds the file and returns it as a response attachment which usually prompts the browser to download the file, and then the second submit action is just the original asp page with the history details. In IE10, the file doesn't download ever and instead some processing occurs and the second submit which reloads the history goes through fine.
What I've found in my looking is that if I comment out the javascript line that submits the second form, then the download works so I think what's happening is the submits are occuring asynchronously and the redirect one returns before the download one. Or something like that. I'm not sure. I'm trying to figure out a work around without having to completely rewrite the feature. Any thoughts?
EDIT:
The page this all occurs on is accountDetails.asp
The javascript --
function SetOFX(type){
// There is some code that does conditional handling of the #type parameter
document.forms.DownloadForm.submit();
document.forms.Finished.submit();
return false
}
The DownloadForm --
<form name="DownloadForm" id="DownloadForm" action="downloadofx.asp" method="post">
<!-- a bunch of input type="hidden" elements -->
</form>
The Finished Form --
<form name="Finished " id="Finished " action="accountDetails.asp" method="post">
<!-- a bunch of input type="hidden" elements -->
</form>
So the DownloadForm calls a separate asp page to get the download file and then the Finished form posts to the page the user is already on to reload the account history details instead of showing the download image buttons. I realize this is a really bad way of doing this in the first place; this is legacy code written by people who were learning and is already being used in production by hundreds of clients so I can't just rewrite it without a major project approval from my boss and all of our clients.
iI haven't tested any of these ideas, but if you want to keep the current architecture, you could try to detect when the file has been completely downloaded and then navigate away.
Have a look at this question to know how to detect when the file has been downloaded by the browser.
Another idea would be to drop the first form submission in favor of a simple a link with an href attribute that points to your file download link, using query string params to pass additionnal data. You might also want to put taget="_blank" on the link if you still experience the same issue without it.
Here's the answer we came up with in the end. The above javascript shouldn't have ever worked in the first place and in fact we found out after testing that it wasn't working in many places but the part we cared about (the file download) was always working. It turns out up until IE10, all browsers have been smart enough to know that you shouldn't submit two forms that way and they ended up ignoring the second submit. IE10 however was processing them both and the redirect was returning before the file download. Since we didn't care about an auto-redirect we just took that submit out and instead added a submit button to the finished form so the user could manually return to the previous view.
The fixed Javascript --
function SetOFX(type){
// There is some code that does conditional handling of the #type parameter
document.forms.DownloadForm.submit();
return false
}
The fixed Finished Form
<form name="Finished" id="Finished" action="accountDetails.asp" method="post">
<!-- a bunch of input type="hidden" elements -->
<input type="submit" value="Return to Account Details" />
</form>
Scenario 1
The page contains nothing but only the 'MultiSelect' user control. Here, jQuery is working well.
Scenario 2
I moved the 'MultiSelect' user control to a project where we use master pages and UpdatePanel. The hierarchy of the page is
Master Page --> Content Page --> Div --> MultiSelect user control
Here jQuery is not working.
About MultiSelect user control
The control having a reference to jQuery file and it contails lot of check boxes grouped. So if I click on group header check box, all the child check boxes will get selected.
My queries are
Why jQuery does not work in Scenario 1 ?
Where is the best place to link the reference to the jQuery file, in Master Page, in Content Page, or in UserControl itself.
I heard about if we use UpdatePanel, we need to use PageRequestManager too.
Writing JavaScript code in Code Behind file will solve the issues ?
Well. While using jQuery in ASP.NET User Control, we have to do the following(all the steps are not mandatory)..
a. You may write code in code behind file. There you have to use PageRequestManager too.
b. You may put reference to jQuery in Master Page.
May be your JQUERY is conflicted with AJAX Javascript.
If you have put our jquery in usercontrol check its path. If the usercontrol in one folder then the path must not according to user control. A path always according to master page or parent page.
You can test you java script error by Firebug or if you have latest fire fox press ctrl+shift+k. the refresh your page and check you function why it is not working. you will find the Java script error.
I have this problem but with lot of test can solved it this details.
Best place to define and import css and jQuery files in asp pages and should not be added in ascx (user control).
Update panel with jQuery and Javascript have conflict so if you use jQuery and Javascript in your usercontrol as well as me, delete update panel nevertheless you can this :
<asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="true" UpdateMode="Always"
RenderMode="Block">
in user control.
And set Script Manager in your master page or asp page that included user controls.
In accordance your help for use PageRequestManager, I try for it, but scripts which generated for page have conflicted with update panel and crashing it.
I was searching for a script or at least a code snippet but haven't really made any progress. Anyway, I'm looking for a script that works like a simple pagination javascript but it should be accessible by linking from anywhere in the document and by calling it with the URL (e.g. on www.abc.de/default.html#thirddiv the third page of the pagination is displayed). Further, the contents should be loaded upon request (when the user clicks on the link and enters the specific page of the pagination), so that cookies, that have been set or deleted in the same document earlier can be used later without reloading the entire page. Something like that is used on Facebook for calling contents and loading them.
I've found a script on CSS Tricks called BetterBlogroll but I don't really get my mind into this. A pagination script from DynamicDrive is already working very well on the page but my problem is that there should be running three of them on the same page and as I said, the content should be loaded upon the user's request.
The script I'd need does not has to be with loads of CSS, the best way would be plain javascript and only the required CSS and HTML data. Anything else just disturbs. If anyone can help me out here, I'd be very thankful.
Check out Ryan Bates's Railscasts #174 and #175. These two are not rails specific, and explain this well.