MasterPage link is changed in sub folder - c#

So I have a link in my header placeholder in my MasterPage that takes me to my gallery
<a href="Gallery.aspx" class="logo-text">
Link is:
http://localhost:50803/Gallery.aspx
I created a subfolder called "Order" and used the MasterPage in one of the pages
Then I tried clicking the link in my header and it took me to
http://localhost:50803/Order/Gallery.aspx
Is there any way to change it so it takes me to the intended link?

Related

Double Clicking Asp button in Designer mode creates function in unwanted aspx.cs fle

On double clicking the asp:Button in Design mode, a button click function is generated in .aspx.cs file of some other .aspx file. How do I make it such that on double clicking the button, it opens in the same page's cs file?
Note: I am using Visual Studio 2022 (free)
Example :-
I have 2 web pages:-
web.aspx (web.aspx.cs)
web1.aspx (web1.aspx.cs)
Now if I double click on a button in design mode of web.aspx file, then a button_click function is being created in web1.aspx.cs file, but Onclick event is being added to the button in web.aspx.
How do I make it such that on double clicking, the function is created in web.aspx.cs itself ?
Most likly the issue is that new page was NOT created by Visual Studio, but you made a copy of the page.
Check the topmost line in the markup page.
so, say the page is called MyUpLoadTest2.aspx
(the "2" kind of gives away the fact that I made a copy of this page).
Note this part:
<%# Page Language="C#" AutoEventWireup="true"
CodeBehind="MyUpLoadTest2.aspx.cs"
Inherits="CSharpWebApp.MyUpLoadTest2" %>
Check both codeBehind, and make sure it matches the page name (MyUpLoadTest2).
And also check the Inherits in above - again make sure it matches the code behind.
Also, view the code page, and make sure the class name for the page matches the page name.
eg this:
public partial class MyUpLoadTest2 : System.Web.UI.Page
So, make sure all 3 match.
if the page directive in the markup does not match the correct name, or is pointing to a different code file, then you see the effect you note - the code will be created in the wrong page.
Another issue/thing to avoid?
Don't name the page the SAME as any class you have - including built in ones, as that can say mess things up.
So, for example, you might try to call a page GridView, but there is a gridview control, and thus you don't want your page to have the same name, since then the code behind page class will wind up with the same name as that existing class (built in ones, or even control names).
So, check your page directive.
In many cases, you are better off to create a new blank page, and then cut + paste in the markup between the "form" tags, and leave the rest of the page alone.

Page link from overriding page to non-overriden page not generated properly

I'm trying to achieve overriding of existing 'Theme' pages, located in 'Pages/Theme', by placing another page with the same name in the 'Pages/Overrides' folder.
I have done so by creating a PageRouteModelConvention named ThemeTemplatePageRouteModelConvention. Any pages in the 'Pages/Overrides' folder will be reachable without the '/Overrides/' route prefix and have priority over the similarly named view in the 'Pages/Theme' folder.
See my example repository here: https://github.com/bryandh/razor-page-override
In the current setup, we have three pages in Pages/Theme:
Index
About
Contact
And two pages in Pages/Overrides:
Index
About
The behaviour that I would like to have with these pages:
Index page with / route used from Pages/Overrides
About page with /about route used from Pages/Overrides
Contact page with /contact route used from Pages/Theme
This works as I want it to work.
However, the anchor tags created in the Pages/Theme/Components/_Header partial to a non-overriden page in Pages/Theme using the anchor tag helper does not create the correct route.
See the root/index page where the _Header component is included. The About page link is generated correctly as the About page is also in the same folder. However, the Contact page link does not seem to be generated properly. This link to the Contact page only works when you're on the Contact page itself, as that is situated in Pages/Theme.
Generation of the anchor tag doesn't seem to take the locations views can be situatied in into account.
Because the link is in a component that I do not want to override, I can't modify the asp-page attribute to fix the problem.
How can I let the Header component generate a link to the Contact Theme page from the overriding Index page?
[UPDATE]
To clarify further, see the page override structure below.
The asp-page tag helper can't find the Contact page to create a route for.
Note: the Contact page is reachable by manually navigating to /contact.

Get a value from clicking on a masterpage hyperlink to child page

I am trying to create a website that will allow sharing photos (as a basic project),
and i encountered a problem.
On my masterPage there are links with category names and I need that when i click on one of them I would get a Value into a variable in a child page (in the css code page).
I am pretty new to masterpages and have no idea how to do so, i tried in some ways but just couldn't.
As an example:
A string variable in the css section of the child page "Gallery.aspx" that would get the value of the category name when it's clicked in the masterpage.
Hyperlink hh=(Hyperlink)Master.FindControl("control_name");
reference

How to set dynamic home page link in image logo?

MySite.com
when I click site logo, wanna appear sitefinity home page. how to set href atrribute in sitefinity as sitefinity CMS is dynamic home page?
there are several ways to achieve this, depending on how you have your logo setup on the page.
Your home page is usually setup to load when you visit the top level domain, which is at the root of your site.
If this is the case and you have your logo defined in a .master page, you can easily set the link to be the root, like
<img />
If, on the otherhand, you have the image on a sitefinity page or template, you need to make sure that you're adding the image inside a ContentBlock, and not the Image widget from the sidebar. This widget is only used to disaply an image, not link one.
by adding the image to the content block, you can then select it and add a link from the radeditor toolbar to the home page (or any other page)
hope this is helfpul!
Another, rather easy way of doing this would be using your url http://www.mysite.com as href for the logo, which is not too bad either (Although not as dynamic anymore)
But still helpful, especially if you are using some code in your print.css that looks like this:
a:link:after,
a:visited:after {
content: " (" attr(href) ") ";
font-size: 90%;
}
and renders href links after your actual links on printed pages.
This would result in something like the below:
[your company logo] http://www.mysite.com

Adding Images to an ASPX page

I have an aspx page which I am pasting the code from. This page is a preview gallery which when I create a new gallery in my admin panel it auto updates to this page and places the text name I assign in the admin and assigns a page link which takes users to the actual gallery page for that preview... for instance I log in as admin and select manage free gallery.. enter the gallery name (for example" free preview") upload 8 or 9 images and a slideshow then hit submit. The gallery is then created and a link to that gallery is placed on my page for all free galleries. I want to not only have a link but an actual thumbnail image for these.. how would I do this given the code I am pasting below? I would also be willing to just eliminate the text link and go with a clickable thumbnail with a short description under it which actually would probably look better anyway. Pasted ASPX Code follows:
ok so I cant post the code because I am new... any suggestions??? I can email code or post else where if anyone has some help info.
Thanks
How do you create your text link? I assume you're using a asp:Hyperlink control and you're just setting its Text and NavigateUrl properties?
Then you can do the same thing and also set the control's ImageUrl property to the URL path of the image.

Categories

Resources