I have an asp.net website that is using update panels on the page that i cant get to reload from the server. I have this for the disable page cache on the master page.
Response.Cache.SetExpires(DateTime.UtcNow.AddDays(-1))
Response.Cache.SetValidUntilExpires(False)
Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches)
Response.Cache.SetCacheability(HttpCacheability.NoCache)
Response.Cache.SetNoStore()
When I click the browser back button to go back to the page it says the page has expired. The other pages on my web site work and call the page load, the only solution i found but cant use is to wrp the whole page in an update panel, but i can't do this because i have a report viewer on the page that does not work with ajax. If anyone can help i would deeply appreciate it.
This is not a browser cache problem; it's a postback one. You have to implement the Post/Redirect/Get pattern in order to avoid the "do you want to submit again? / page expired" message.
http://en.wikipedia.org/wiki/Post/Redirect/Get
The classic example for this thing is when a web page has a save button that insert something in a Database. The "Save" button is clicked -> a postback occurs -> code insert a row in a table -> user refres the page (F5) -> postback occurs again -> code insert the same row again.
To avoid the double insert in the previous example you need to redirect when the "save" button is pressed and only then, execute the insert.
Just add this in your view file in header part:
<head>
<script language="JavaScript">
<!--
javascript:window.history.forward(1);
//-->
</script>
</head>
Inside body tag add this:
<body onUnload="OperaReload()">
<input type="hidden" id="refreshed" value="no">
To reload the page with JavaScript use the following:
window.location.replace(window.location.pathname);
Related
My /htmx webpage has a list of links like this one:
<li class="collection-item" hx-push-url="true" hx-post="/htmx/file/open/specification.idp"
hx-trigger="click" hx-target="#screen">Click me</li>
When I click it, the #screen target is correctly updated, and the browser URL is correctly changed to /htmx/file/open/specification.idp (thanks to hx-push-url="true").
When I click the browser back button, the original htmx page is properly displayed, but the browser URL remains /htmx/file/open/specification.idp, instead of becoming /htmx.
How can I get the browser URL to be /htmx? I'm using Htmx 1.8.0. I also tried using hx-get.
I have a dashboard with a submit button (submitButton). The search isn't run until the button is pressed which is exactly what I want (the search takes a long time). I don't want the search starting as the user changes the other dropdowns (time), environment (Prod vs. QA), etc.
HOWEVER, sometimes it would be nice to hit the submit button and perform the search again without changing any of the other fields (time, environment, etc.). In this case the submit button does nothing! I can tell the underlying data has changed via searches, but the dashboard is not updated. Simply changing any of the fields, doing a search, and then changing them back and searching again solves the problem, but surely the submit button should just work w/o this workaround?
Thanks
If "nothing" has changed, then Submit is supposed to "do nothing".
If you want to refresh the page with all the parameters as set, you should be able to click the URL bar and press return (so long as there are no hidden tokens, they'll all get set in the query portion of the URL).
Each panel in the dashboard should (automatically) have a refresh button you can click to refresh the display without changing inputs.
Unfortunately, this is intended behavior.
I also wish that the submit button would rerun dashboard searches. I opened a post on Splunk ideas about this issue:
https://ideas.splunk.com/ideas/EID-I-739
If you have a splunk.com account, you can vote for this idea.
I've browsed through Internet and found some solution that with some modifications worked for me fine
<form>
..
<html>
<style>
div.fieldset.dashboard-form-globalfieldset div.dashboard-element.html.dashboard-element-html {
display: inline-block;
}
</style>
Refresh
</html>
...
<form/>
so basiclu im refreshing page with all of its attributes and passing attributes values form current ones chosen using tokens. splunk code didn't like & so replaced it with & and it worked fine. <> - can be found in your splunk page address.
The scenarios is when you click on submit button on page A, it redirects you to Page B most of the time but there are some conditions when it will take back you to Page A without going to Page B.
Also, there can be frontend validation errors which sometimes prevent the submit button to take control to the next page.
So I exactly want to verify that when I clicked on submit button it has taken me to Page B or if page A is displayed again it is not because of validation errors but it is the fresh page came after redirection.
Make sure your URL get changes after click on submit button If Yes the you can use below code
String currentPage=driver.getCurrentUrl();
driver.findElement(By.yourLocatorForSubmitButton).click();
String newPage = driver.getCurrentUrl();
if(currentPage.equals(newPage))
{
System.out.println("On Same Page");
// Here you perform your further action if there is some validation error then get those validation and fullfill the condition
}
else
{
//carry on your further action comes on new page
}
There are two ways to make sure that we have successfully navigated to page B after clicking submit button in page A:
By checking the existence of any locator(Usually title of the page or buttons) of page B after clicking submit button on page A.(recommended)
*Selection of locator should works in all circumstances
Check for change in URL.(Less preferable )
1.Check for the change in the url of the page.
2.Compare the content of the page before and after clicking the submit button.
I am getting this error most of the time when I submit my form. I am using Sitefinity 6.2 with ASP.NET MVC 4.0 and JQuery Mobile.
As I have Sitefinity in Hybred mode I am using the #Html.BeginFormSitefinity() command to create the form. On the Controller I have my action with the [HttpPost] attribute. The code always hits my default action on the controller with no problem. No matter what I put in the form when I submit I only get an error message on the page...never hits the HttpPost action.
I've looked around and there are many pages with fixes for the MAC failed issue, but none are working for me. I have a machine key in the web.config and I am NOT going to set enableViewStateMac to false as that is a security hole.
OK I tried working with both of the below solutions but they are both really bad. Here is what I am doing now, which is still not great, but I have Sitefinity, MVC, and JQuery Mobile all on the same page and forms are not giving me View State Exceptions anymore.
First thing is that adding data-ajax="false" is not enough, for this to work you need to disable Ajax before JQuery Mobile starts. So, to do this you need to add in this script BEFORE the JQuery Mobile File loads but after the JQuery file loads.
$(document).bind("mobileinit", function () { $.mobile.ajaxEnabled = false; });
After doing this I then do not use the Sitefinity Begin Form, I just JQuery to change the form on the main page to have the correct action.
<script>
$("#aspnetForm").attr("action", "Home/Login");
</script>
Together this means that there is a complete page load for each page change, and form posts use the form declared in my WebForms Master Page.
-Old Answer -
Actually...what I have below is not working. What I am
currently doing is really ugly but is usually working.
As long as the user enters the site from the home page then the home
page is the Jquery Mobile first page. The view state errors that I
was getting was because it saw the current page as the first page and
the form submit was to the active page. What if the controller for
the home page was just set to handle ALL HTTPPost calls? I have
removed the #Html.BeginFormSitefinity() from all the views with forms
and am just using the form on my top level masterpage. Then I add in
code on the view to change the action of this form to point to the
main page controller. ex
<script>
$("#aspnetForm").attr("action", "Home/Login");
</script>
Once I made this change the forms are not throwing view state
exceptions...as long as the home page is the Jquery Mobile first page.
If the user comes in from a different page then all is scrambled.
Don't have an answer for that yet.
Really Old Answer -
OK, think I have found it. I read somewhere, lost the link now, a
list of issues that can cause the error message. One of them is the
form being submitted from a different page.
I looked at the error message I was getting with Fiddler and noticed
that the Referer was my home page but the URL of the form post was the
URL for the page with my form. In stead of browsing through my site
to the page with the form I typed the URL in the address bar. I tried
submitting my form again and now it works!
So, this is an issue of Sitefinity and JQuery Mobile fighting it out.
When asp.net MVC is run in Hybred mode in Sitefinity it is actually
run in a Web.Forms master page that contains a form. When you use the
#Html.BeginFormSitefinity() to add a form to the view it is actually
just adding a div and then using AJAX to submit the form on the
Web.Forms master page.
JQuery Mobile loads up the first page that you visit, but later pages
are just injected into the existing page. So, there are multiple
data-role="page" divs loaded up in the DOM, inside of the Sitefinity
Web.Forms Master Page.
This all together is causing the form to post with the URL of the
active data-role="page" but the server sees that it is being refered
from the original page I loaded up. So, if I went to the page with
the form first all would work, start at any other page it does not
work.
Now that I know this I can put in data-ajax="false" on the link to the
page with the form and all looks to be working. This will cause
JQuery Mobile to not inject the target page into the current page but
will load all fresh with the target.
data-ajax="false" is the answer!
I am making form with submit button in Joomla custom HTML and I would like to stay on the same page after I click on the submit button.
Is that possible? Thanks in advance.
Just leave the form action attribute out. This will post back to the same page. Have a look at this question and answer: Is it a good practice to use an empty URL for a HTML form's action attribute? (action="")
If "stay on the page" means that the page will not reload, or anoter page will be loaded, yes, thats quite possible. I think the best way of doing this is replacing the <input type=submit> with a <button>, which calls a javascript function that evaluates the form, submits the data via ajax, and notifies the user that the form was successfully submitted.