GWT History Problem - url

when i am adding a new history item like this
History.newItem("Register");
the url correcly changes to
http://127.0.0.1:8888/BiddingSystem.html?gwt.codesvr=127.0.0.1:9997#Register
and loads the register form
but then the url automatically rechanges to
http://127.0.0.1:8888/BiddingSystem.html?gwt.codesvr=127.0.0.1:9997#
why??
because I want to remain as
http://127.0.0.1:8888/BiddingSystem.html?gwt.codesvr=127.0.0.1:9997#Register
so that user can reload

The problem is that I was using an hyperlink for acting like a click handler. with a hyperlink, event if u place an empty string, it gonna change the url.
e.g. if the current URL is something like http:...//#This and a hyperlink has an empty target history token then, the url is to change to http:...//#.
The solution i used that worked for me is that because i does not want to use a button, i make use of label and adding some css to it to make it look like a hyperlink
for e.g.
Label Register= new Label("register");
Label.setStyleName("FalseHyperlink");
then in the css
.FalseHyperlink
{
color:blue;
}
.FalseHyperlink:hover
{
text-decortion:underline;
}
Here this solution worked for me because i was not interested in other hyperlink services such as visited or others

Check if any empty string added to History after page rendered or correct history token added to history? URL is changed when a string added to History.

Related

How to change URL names in Umbraco

This is my first time round using Umbraco and I have created Document Types / Pages using the wrong naming format and now this has transpired into my page URL's, for instance /about-page/. How would I go about changing them to /about as I have searched the back-end admin panel and there dose't seem to be an option to change their link to document values.
Would anyone be able to provide a simple code based example using umbracoUrlAlias or umbracoUrlName how I could change this preferably in Razor.
Thanks
Editing #run yards Solution by digbyswift help in comment
Correct Solution:
Create Property on in Document Types which applies to all pages you want to change the URL
Call the name anything you want e.g Page URL and Possibly give it a new tab.
Call the alias umbracoUrlName
Type as text sting
Should not be Mandatory (As when you start replacing .Url with .umbracoUrlAlias within the views it will need to be present)
Tab as Generic
Click Save on top right on the page
Added screenshot for starter kit on Umbraco v7.2.5
Unless I'm very much misunderstanding your issue, you should just be able to change the name of your page and republish. This doesn't need an additional field, just change the value in the "Properties" tab and republish the page. This will automatically change the URL of the page.
You can also create a property called umbracoUrlName using a TextString property editor. If this has a value then it will generate the URL fragment for the page using this value, rather than the page name. This changes the URL for the page, rather than creating an alias, like umbracoUrlAlias.
Solution:
Create property on in Document Types which applies to all pages you want to change the URL
Call the name anything you want e.g Page URL and Possibly give it a new tab.
Call the alias umbracoUrlAlias
Type as text sting
Make it required (As when you start replacing .Url with .umbracoUrlAlias within the views it will need to be present)
Go into all your pages and rename them using the property you just created
Now with your code, say with the navigation where you have used .Url change it to .umbracoUrlAlias and the new URL's will be used.
Note if you don't use .umbracoUrlAlias the links will still be active i.e. they work but they won't be displayed in the address bar as .Url spits out the original ones associated with the page.
You can apply on URL names in web.config:
In section find:
<add key="umbracoUseDirectoryUrls" value="false" />
this will set url names for new created items to name.aspx
If you set this to 'true' then new items will be named like /name/
Additionaly you might want to avoid of Handling some urls by Umbraco pipline, just use this setting - add URLs which must be bypassed:
<add key="umbracoReservedUrls" value="~/config/splashes/booting.aspx,~/install/default.aspx,~/config/splashes/noNodes.aspx,~/VSEnterpriseHelper.axd" />

how to set navigate url to hyperlink through c#

am developing an application in which i have to show the customer purchase details supplier wise. for that i have develop user control an add it on page. but the problem it that on user control i need to add a ling to promotional offer page for that supplier which show the current offers of the supplier. for that i have added the hyperlink as fallow to user control
<asp:HyperLink ID="PromoLink" runat="server">Have promo Code ?</asp:HyperLink>
and set the navigation URL as fallow
PromoLink.NavigateUrl = "Promotion.aspx?Filter=" + dt.Rows[0]["SuppId"].ToString();
but when page is load in does not render the navigation url to the link.
i donot why it does not render the url plz help to get out of this.
thanks in advance.
Make sure that the pathing is correct for the NavigateURL property. Try adding "~/" at the start of the NavigateURL or "../" if it is not in the same folder as the current file.
Make sure that the dt.Rows[0]["SuppId"] is actually getting the value that you expect.
Step through code in the debugger to verify that the Page_Load event that you are using is actually executing and modifying the value as you would expect it to.

way to reinitialize a page each time it is shown

I have some pages which are filled dynamically by content loaded with Ajax. My problem is that each time I go to this page, the old content is still there if it hasn't been replaced by new content...
I've thought about 2 home solutions like:
Creating a "template" page. By calling "pagebeforeshow", I'll copy the code from the template in the target page, and add there the dynamic content...
Each DOM where dynamic content must be put into, I had a class "clearcache" and by calling "pagebeforeshow" I do a $(".clearcache").empty();
I don't know how to deal with that. Have you ever got the same issue?
EDIT:
I bind the "tap" event to store the block-id into localstorage, to load dynamic content in the #PageBlock
Everything works very well (tap event, localstorage for the var, ajax loading). The issue comes really when I go from block to other blocks. The new content overwrite old content instead of beginning from a new "blank" page.
For example I have a list where I append datas I get from Ajax. If I switch to another block, the list is completed and not refreshed..
I could do something like empty the list, and then appending content, but I'd like something better because I have several pages/lists/dom like that...
Thanks for your help ;)
I faced a similar problem where the new contents where not shown on the page when i tried to append it.There is a simple solution where you can just replace append with prepend.
Example:
Replace
$("#divid").append(content)
with
$("#divid") .prepend(content)

smartgwt browser history

is there a way in smartgwt to go back in history?
E.g. I have an page with a button which does a Ajax page change of the current page to another. And on this new page there should be a button to return back to the previous page?
Can this be done with smartGWT? or do I have to make a new Ajax call to switch back to the previous page?
The functionality you want is provided by History class. Need to declare in web.xml and then use History.fireItem("SomeURL"), this will appear in app url as the string after # in URL is History ID ( something like http://google.com#SomeURL), you can use arbitrary IDs.
Use History.registerCallback() to register a function that opens requested History ID (eg. tab name/ID) on URL change (History's ValueChange function) and use History.addHistoryEntry() to update the page URL when other tab is selected.
If you implement this History class then you can use the browser's forward and back icon for the same purpose.

Adding a "previous" link

What the appropriate way to do this?
ViewData["PreviousPage"]=Request.UrlReferrer.PathAndQuery;
this doesnt work if directly accessing.
EDIT: I did a null check on Request.UrlReferrer, seems to be fine (?)
If directly, it's impossible this way. URL referer is set only when clicking a link.
If you're interested only in "Previous Page" link working inside your website, then you can store current URL in session, and retrieve it during next request, then replace with a new current url. Ugly, but working.
Is there some reason this needs to be server-side instead of client-side? If you can deal with client side, Javascript is the answer:
<input type=button value="Back" onClick="history.go(-1)">
This uses the browser's built-in back functionality -- it essentially mimics clicking the "Back" button.
Put this somewhere in your Base Controller or Custom Filter:
TempData["PreviousPage"] = TempData["CurrentPage"];
TempData["CurrentPage"] = Request.Url;

Resources