I am really confused about this one. I have some code that runs fine on my development server but I am now trying to get the site working on the sales guys new laptop. None of the image buttons on the website seem to be working for him (they just redirect me back to the websites homepage) whereas they used to on his previous machine.
The only difference between each machine is that his old one was Vista and the new one is Windows 7.
Has anyone come accross this issue?
Some code:
The form:
<div class="form_text"></div>
<div class="form_box_link">
<asp:ImageButton id="LoginSubmitButton" onClick="FLoginWebService" ImageURL="~/Images/login.png" runat="server" />
The code behind (delphi):
procedure TMemberLogin.FLoginWebService(Sender: TObject; e: System.EventArgs);
begin
//Code Removed but using OutputDebugString shows nothing is being done in here
end;
As mentioned, this works everywhere else except on his windows 7 machine.
EDIT: Ok, I have some more information that has helped me. It seems ALL the post back URLs are incorrect. I manually set the PostBackUrl against the ImageButton control and got this part working but ALL other controls that require post backs on the website do not work properly and are posting to the wrong URL's. I am using IIS's rewrite module but this is the only machine that I am having an issue with it on.
I have managed to sort this issue out. It turns out the problem was the URLs ASP.NET was using for the post back. I am not sure what caused this issue (there must be a different setting somewhere) but I have added some JavaScript to the top of my page to sort the issue. ASP.NET initializes a var called theForm so I just did:
theForm.action = window.location.href;
and that sorted the issue out.
Thanks for any comments people have made.
Related
I have a website with a page that does a crosspage postback using an ASP:Button with a PostBackUrl as such:
<asp:Button ID="FindButton" runat="server" Text="Find" CssClass="button" PostBackUrl="~/TGS/BusinessResults.aspx" meta:resourcekey="FindButtonResource1" />
I do not need information about the previous page other than PreviousPage.IsCrossPagePostBack, so adding a PreviousPageType should not be neccesary.
Problem
I have two machines, one laptop and one desktop. My code works as intended (PreviousPage is not null) on the laptop, but PreviousPage is always null on my desktop with identicical code.
I have the same Visual Studio 2010 installations with the same .NET versions (Used System.Environment.Version to check) on both machines.
Any thoughts?
Edit: as an update, this is no longer neccesary - I fixed my issue (which doesn't really have much to do with this) in a different matter - but as always; i'll include my solution:
I was using some Response.Write to write a loading gif to a website while the actual page loaded, and this messed up some form related things.. I included a base target to the header of the loading gif html and that solved my problem of all links opening in new images.
A null PreviousPage can be caused by a transfer that might be induced through an intervening Web proxy or perhaps a caching appliance inline with the desktop, but not the laptop. I'd pull a Net Monitor and/or ProcMon trace to see if anything like this might be at play. Hope that helps in some way.
I don't really know where to start with this one. I am getting:
`Failed to load viewstate. The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request. For example, when adding controls dynamically, the controls added during a post-back must match the type and position of the controls added during the initial request.`
after moving a website to a new server. The exact same code works on my other server. It happens when I submit one of my forms (but doesn't do it on all form submissions).
Any ideas what can cause this so I have somewhere to look?
Using: ASP.NET 2.
EDIT: I am adding some user controls to a placeholder dynamically at runtime but this same code is working ok on my other server. I have tried clearing the controls in the place holder before adding new ones (as I saw a post about that) but it hasn't helped.
EDIT2: It seems that the postback is just failing. It isn't going into the onClick code of the button either so something is deffintiely screwy .. If I try / catch the exception it seems that all the controls are still added successfully ... Setting my Dynamic UC's to EnableViewState = false resolves this particular error.
EDIT3: Ok, I think I may have a handle on what is happening. For some reason on the old server the form action is default.aspx?action=amend but the new server is showing amend.html?action=amend so I think the re-write module is messing up in IIS. This would explain the control adding issue as well because the action is happening 2 times (I think). I will look into the Rewrite module and see if anything is wrong then post back.
Please, have a look at these articles:
http://blog.typps.com/2008/01/failed-to-load-viewstate-typical.html
http://weblogs.asp.net/guys/archive/2004/12/05/275321.aspx
Or try a simple temporary solution - disable viewstate for this placeholder. Either way, I'm puzzled why it actually works on your first server. I'd be glad if someone else will be able to clarify this subject more.
It turns out that the post back Url for the form is wrong on this server (unsure why at the moment, I will update when I know). This is causing the dynamic controls to be added in an unexpected way and causing the error. I noticed this when I managed to post my form and the content didn't update. I manually adjusted the action url using firebug and all is well.
Worth looking at walther's answer regarding dynamic controls and the viewstate though.
Not sure what caused it but I am manually setting the form action in the page load now and it seems to have solved the issue.
I have seen a few posts regarding this issue but not one specific to my problem and I have no ideas as to what I need to do to debug this.
I have some combo boxes on an aspx pages, when I select a value from the first one, it fills the second with value and so on with the third and fourth. This works with no problems until I wrap an asp.net UpdatePanel around the combo boxes and try to "ajaxify" the whole process so the page isn't dancing around. The exact error I get is:
Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occurred while processing the request on the server. The status code returned from the server was: 404
Some things to note:
I am using URL rewriting - This is what I think is causing the problem
The error will occur whenever I choose a selection for a SECOND time. This means that I could select a value from the first combo box and get the same error (so it is happening on the second postback - No matter which combo box it's from).
I have tried setting the EnablePartialRendering="false" on teh scriptmanager but as I said, it works when not using ajax, so I don't know how to debug the issue.
My server is Windows 2008 running IIS& with ASP.NET 2.0.
I would really appreciate your help
Thanks in advance.
Ok, I have managed to find a solution ... minutes after posting.
I used HTTPWatch to get the URL the request was being posted to. This showed me the URL was Appending to the existing URL each post and not overwriting. I used some JavaScript at the top of my page to set the forms URL to the window location:
Sys.Application.add_load(function()
{
var form = Sys.WebForms.PageRequestManager.getInstance()._form;
form._initialAction = form.action = window.location.href;
});
This sorted it.
Hope it helps someone else.
Use Response.Redirect() instead of Response.Transfer() if you use.
We have an ASP.NET application that we recently migrated onto a new server with IIS7 and .NET 3.5.
In this new environment, some users that are on IE (6, 7, or 8) are experiencing bizarre intermittent problems with postback not working on ASP.NET buttons. (you click the button and nothing happens)
The issue happens sporadically. Sometimes it works, sometimes it doesn't. For some users the button postback almost never works (but sometimes yes!). To complicate matters there are some pages with asp.net button postbacks that DO always work.
Other pages contain a mix of 'asp buttons' and 'asp link buttons', in which the asp button postbacks often don't work, but the link button postbacks always work.
Javascript is enabled and works. The source DOES contain valid tags.
I actually managed to take View Source snapshots of the same page when it was working and when it was not working and the source was EXACTLY the same!!!
At first I thought it was a problem with IE6, but it's now been reproduced on IE7 on one user's machine.
How would I even BEGIN to tackle this problem?
Any help, ideas, or guidance would be vastly appreciated. I am at the end of my mental rope here.
I know this topic is pretty old, but I found the same problem in my code.
I am using the ComponentArt component library.
In certain circumstances after a postback, buttons with codebehind will no longer execute in IE. I also noticed that buttons with onClientSide clicks would execute their postback when the JS function completes and returns true.
I was able to get all the buttons on the page to submit by adding the following code to my buttons:
OnClientClick="javascript:return true"
Any buttons that are already running a JS function and returning true, should work without issue.
See if this post helps? IE 6 treats buttons a little differently, especially if you have some name conflicts. I could see this being a problem for events if that is the case.
Found the culprit.
It was ComponentArt's 2007 Web.UI components that were being dropped on the page.
Apparently the menu control mixed with the 3.5 framework causes wierd issues with postback not working.
I designing a web application using vs2008 and c#.
I already have done many versions of it and all of them seems to be working fine.
Yesterday i decided to replace de vs calendar with a ajax calendar and to do so i used ajaxcontroltoolkit. The new calendar is also working fine.
But the buttons i have in my form stoped to work.
The onclick event just do nothing.
i've already change back to the older calendar and everything works ok.
The button calls a method on code behind.
So, any of you guys have a clue about what i'm doing wrong?
Is there other ways of doing this?
Tks in advance
thanks for yours answers
my problem is that i'm using this onsubmit="return setHourglass(); on my form so the user know when the page is waiting for a response.
Something like this:
Bellow the script code
function setHourglass() {
document.body.style.cursor = 'wait';
}
i removed that and is working ok, but i really don't know the motive for this behaviour :|