I got silly problem. I use on image href statement for url redirection.
SO i got this menu tab
<asp:MenuItem NavigateUrl="~/Default.aspx" Text="Home" />
<asp:MenuItem NavigateUrl="~/Test/TestODS.aspx" Text="Katalog" Value="Katalog"/>
<asp:MenuItem NavigateUrl="~/UploadNewOne.aspx" Text="Upload" Value="Upload"/>
and my image:
<a href='~/Default.aspx'>
<asp:Image ID="Image1" runat="server" Height="70px"
ImageUrl="~/Images/i-sova.jpg"/>
</a>
So problem is that when i click on Katalog , app redirect me on sub-domain Test/TestODS.aspx. From this page when i click on image im redirect on wrong url which doesnt exist >> /Test/Default.aspx
So anyone can help?
To use a tilde, you will need to add runat=server to the <a> tag
<a href='~/Default.aspx' runat="server">
Related
I've been working through an issue where I want to update some control states prior to downloading a file. Using info from other StackOverflow users, I've arrived at a solution that works 'mostly'. I'm updating my controls in the main button click handler then using a RegisterStartupScript to execute a click on a hidden button to perform the actual download.
All that works as-expected.
The issue I'm coming across is that the placement of the startup script seems to be interfering with the normal rendering of my menu at the top of my page.
Normal Menu
Corrupted Menu
I have a menu setup in the site masterpage using an asp:Menu control and LoginView, and this ends up adding a new Sys.WebForms.Menu script at the bottom of the page through whatever magical mystical potion Microsoft uses for this control.
The last few lines of my html source ends up looking like this when the RegisterStartupScript is run:
<script type='text/javascript'>document.getElementById('btnHiddenDownloadAction').click();</script><script type='text/javascript'>new Sys.WebForms.Menu({ element: 'MenuLoginView_NavigationMenu', disappearAfter: 500, orientation: 'horizontal', tabIndex: 0, disabled: false });</script></form>
</body>
</html>
The first script with the btnHiddenDownloadAction click is what I'm adding via the RegisterStartupScript() call. The second script is getting placed there by the ASP.NET menu control.
The menu control on my masterpage is defined like this (truncated)
<asp:LoginView ID="MenuLoginView" runat="server" EnableViewState="false">
<AnonymousTemplate>
</AnonymousTemplate>
<RoleGroups>
<asp:RoleGroup Roles="Administrator">
<ContentTemplate>
<asp:Menu ID="NavigationMenu" runat="server" CssClass="menu" EnableViewState="false"
IncludeStyleBlock="false" Orientation="Horizontal" OnPreRender="NavigationMenu_PreRender">
<StaticSelectedStyle Font-Bold="true" />
<Items>
<asp:MenuItem NavigateUrl="~/KeyGeneration.aspx" Text="Feature Activation" />
<asp:MenuItem NavigateUrl="~/GenerateAALicense.aspx" Text="Generate AA License" />
<asp:MenuItem NavigateUrl="~/DevicePasswordGeneration.aspx" Text="Device Password Generator" />
<asp:MenuItem Text="Reporting">
<asp:MenuItem NavigateUrl="~/KeyHistoryReport.aspx" Text="Feature Activation History Report"></asp:MenuItem>
<asp:MenuItem NavigateUrl="~/AALicenseReport.aspx" Text="AA License Report"></asp:MenuItem>
<asp:MenuItem NavigateUrl="~/DevicePasswordHistoryReport.aspx" Text="Device Password History Report"></asp:MenuItem>
</asp:MenuItem>
<asp:MenuItem NavigateUrl="~/ManageUsers.aspx" Text="Manage Users" />
<asp:MenuItem NavigateUrl="~/ManageFeatures.aspx" Text="Manage Features" />
<asp:MenuItem NavigateUrl="~/ChangePassword.aspx" Text="Change Password" />
<asp:MenuItem NavigateUrl="~/About.aspx" Text="About" />
</Items>
</asp:Menu>
</ContentTemplate>
</asp:RoleGroup>
I've tried inserting this as a client script rather than a startup script, but the button control doesn't exist at that point, so the button click doesn't execute. I've tried reformatting the script to add a 'div' tag, and I've tried simplifying the call to call a script defined elsewhere, both of those still have that menu problem.
I have a folder in my website called order in which 2 pages "Partner.aspx" and "ViewBasket.aspx" are present. In my first page i.e Partner.aspx, I have a button with the code :
<asp:Button runat="server" ID="btnViewBasket" PostBackUrl="~/ViewBasket.aspx"
SkinID="MSWButtonM" Text="VIEW CART" meta:resourcekey="btnViewBasketResource1"/>
But on click of this button it doesnt go to the Viewbasket.aspx page.
Can somebody please help?
Try,
<asp:Button runat="server" ID="btnViewBasket" PostBackUrl="/order/ViewBasket.aspx"
SkinID="MSWButtonM" Text="VIEW CART" meta:resourcekey="btnViewBasketResource1"/>
Im posting and redirecting to a third party by setting the PostBackUrl property on a LinkButton.
My problem is that I want this to open in a new tab but target="_blank" doesnt do anything here.
<asp:LinkButton ID="hlApplication" runat="server" Text="Start your application" aria-describedby="information" target="_blank" OnClientClick="this.disabled=true;" UseSubmitBehavior="false"/>
hlApplication.PostbackUrl ="http://externalurl";
Any ideas how I can do this?
Try this:-
<asp:HyperLink ID="HyperLink2" runat="server" NavigateUrl='http://www.google.com' Target="_blank">Google </asp:HyperLink>
In this instance, we had to have a hyperlink that opened a new tab that contained the form. This form is automaticaly posted by Javascript and the user taken to their destination. This was the only way we could get this to work
I have an asp.net menu with a few menuitems. 1 of the items has submenuitems.
Problem is that after clicking around on my site for a while, the menu's formatting will suddenly get messed up (the background image will only show in a tight rectangle around the text, and the text will be lower than the separator images) and the text of the menuitem with submenuitems has the phrase Expand MenuItem_Text added to it ("Setup" -> "Setup Expand Setup"), but it's not actually expandable.
I've discovered that logging out and then logging back in solves this, as does clearing the cache, however, I can't expect my users to know that.
I already have the AppleWebKit line in my code, so it's not that.
Edit:
<asp:Menu ID="Menu1" runat="server" Orientation="Horizontal" BackColor="transparent"
StaticMenuItemStyle-ItemSpacing="0" StaticEnableDefaultPopOutImage="False" DynamicEnableDefaultPopOutImage="false">
<Items>
<asp:MenuItem NavigateUrl="~/Main.aspx" Text="Home" SeparatorImageUrl="~/Images/menubarmid.png" />
<asp:MenuItem Text="Setup" SeparatorImageUrl="~/Images/menubarmid.png" Selectable="false">
<asp:MenuItem NavigateUrl="~/ASetup.aspx" Text="A" />
<asp:MenuItem NavigateUrl="~/BSetup.aspx" Text="B" />
</asp:MenuItem>
<asp:MenuItem NavigateUrl="~/Logout.aspx" Text=" Logout "></asp:MenuItem>
</Items>
<StaticHoverStyle CssClass="static_hover_style" />
<DynamicHoverStyle CssClass="dynamic_hover_Style" />
<StaticMenuStyle CssClass="static_menu_style" />
<DynamicMenuStyle CssClass="dynamic_menu_style" />
<StaticMenuItemStyle CssClass="static_menuitem_style" />
<DynamicMenuItemStyle VerticalPadding="3px" HorizontalPadding="10px" CssClass="dynamic_menuitem_style" />
</asp:Menu>
I came up with the same sort of issue and I found that setting the StaticPopOutImageTextFormatString property to an empty string made the equivalent of " expand Setup" to disappear .
It looks like Chrome was trying to display the alternate text for the pop-out image instead of simply not displaying an image to indicate that the link could pop out.
As such my asp code looked something like this:
<asp:Menu ID="Menu1" runat="server" DataSourceID="SiteMapDataSource1" Orientation="Horizontal" StaticEnableDefaultPopOutImage="False" StaticPopOutImageTextFormatString="">
</asp:Menu>
This, in addition to the AppleWebKit code seems to allow my code to work. I did have to do a shift F5 in order to reset the cache every time I restart the test server.
I had this happen to an asp.net site of mine when it was deployed to a server. I eventually found that in IIS the target framework for the site was 2.0. I changed it to 4.0 and hey presto the sitemap menu worked as expected.
I am quite new to ASP.Net. I have a Master.aspx and a Page1.aspx and Page2.aspx, all in the same directory.
Master:
<asp:HyperLink NavigateUrl="Page1.aspx" runat="server" Text="Page 1" />
<asp:HyperLink NavigateUrl="Page2.aspx" runat="server" Text="Page 2" />
both the Page1 and Page2 gets rendered from above master page.
all three are in a vertual directory which is mapped as a subdomain here are the details:
Virtual Drectory: dirvir
Domain: dirvir.example.com
now when I open any of the page say:
http://dirvir.example.com/Page1.aspx
the Hyperlinks are rendered containing
href="../virdir/Page1.aspx"
href="../virdir/Page2.aspx"
respectively.
On click of them it takes me to
http://dirvir.example.com/dirvir/Page1.aspx
http://dirvir.example.com/dirvir/Page2.aspx
where as I wanted it to be
http://dirvir.example.com/Page1.aspx
http://dirvir.example.com/Page2.aspx
I can achive the same by using <a> but i need them on the code behind too so thats not desired.
Note: using <a> with runat server also
behaves in the same way HyperLink
does.
Can you try this as indicated below change the NavigateUrl,
<asp:HyperLink NavigateUrl="~/Page1.aspx" runat="server" Text="Page 1" />
<asp:HyperLink NavigateUrl="~/Page2.aspx" runat="server" Text="Page 2" />
Or
<asp:HyperLink NavigateUrl="/Page1.aspx" runat="server" Text="Page 1" />
<asp:HyperLink NavigateUrl="/Page2.aspx" runat="server" Text="Page 2" />
In Visual Studio click on the Project Name in the Solution Explorer. Once you do this, you will find a property under the properties window called Virtual Path, which will have the value /dirvir. Change this to /
If you don't need it to be a server-side link, just use a regular anchor tag and let ASP.NET figure out the correct path based on your virtual directory for your web application:
Page 1