I am currently using a iframe on my main web page. When i click on a link in the iframe I would like it to display the content on the main web page. Any thoughts?
Set the target="_parent" on the link.
Another way would be to put this into the page that represents the content of the IFRAME:
<base target="_parent" />
I haven't worked with iframes in ages, but I believe it's just <a href="myLink.html" target="_parent" />
use target='_top' on the link in your iframe
<a href='http://example.com' target='_top'>My Link</a>
This will result in the full window/tab of the browser being replaced with the content of the link. You could also use _parent as the value of the target attribute. That would result in the immediate parent of the iframe being replaced which may be what you want. It's possible though for iframes to be nested, so if a.html contains b.html, which contains c.html, a _top link in c.html would replace the entire page (a.html), but a target of _parent would only replace b.html.
Related
I need to access an html page "Pages/createCampaign.html" and/or "Pages/addCampaign.cshtml" and/or "wwwroot/html/insertCampaign.html" (I've created more as tests, but none seems to be working) from a click on a button inside "Pages/Index.cshtml".
Inside html.cshtml:
<button type="button" class="create_but">
<a href="../Pages/createCampaign.html">
Create Campaign
</a>
Follows the tree:
Inside I've tried href="../Pages/createCampaign.html", href="../Pages/addCampaign.cshtml", href="../wwwroot/html/insertCampaign.html", and way more using tilde and more options.
The only one I can access from Index.cshtml is the one in wwwroot/html folder BUT from there it can't find wwwroot/js and wwwroot/css whereas it can finds ~/css and ~/js from Pages.
What I need to do is to open the page to insert/create/add a Campaign from clicking that button in Index, but of course from there I need it to be linked to my css and js files.
How could I solve this situation?
I've read everything I found about static files and web root.
Without specifying the file type from Index.cshtml I'm able to find addCampaign.cshtml like this:
<a href="~/addCampaign">
Create Campaign
</a>
And seems like it can access js and css by <script src="~/js/site.js"></script> <link rel="stylesheet" type="text/css" href="~/css/site.css" media="screen"/>
I have a _layout.cshtml which contains everything but the page-specific body of the website. Within this layout I have a header that looks like this:
<div id="header">
<img src="Content/Images/header.jpg" />
</div>
The navigation menu consists of a few ActionLinks that redirect me to the corresponding view.
My problem is that whenever I navigate to a page that is NOT the homepage, the header disappears. I can't see why this would happen, because every _layout is the same, right?
Thank in advance.
Use <img src="#Url.Content("~/Content/Images/header.jpg")" />
Well it looks like I used some wrong pathing. The following change in code fixed the problem:
<div id="header">
<img src="../Content/Images/header.jpg" />
</div>
The child views need an indication that they need to search in the parent folder.
ASP.NET includes the Web application root operator (~), which you can use when specifying a path in server controls. ASP.NET resolves the ~ operator to the root of the current application. You can use the ~ operator in conjunction with folders to specify a path that is based on the current root. In your case use <img src="~/Content/Images/header.jpg" />
how do i create a iframe refresh ads banner code NO PAGE REFRESH ,not adsense
example =>
<div align="center">
<iframe src ="http://www.1pars.com/ads/2.html" id="I1"
name="I1" align="center" height="63" width="500" "border="0"
frameborder="0" scrolling="no" marginheight="1"
marginwidth="1"><p>Your browser does not support
iframes.</p>
It's simple as this:
<iframe src="../../../index.htm">
<p>Your browser doesn't support frames. You can visit the site directly via
this link.</p>
</iframe>
The linked index.html needs to have this in its header:
<meta http-equiv="refresh" content="15; URL=index.html">
The question is fairly generic; however, if you want to just have an iframe load a banner image, and then have that banner image refresh dynamically, the best choice to me would be an ajax request to the server to fetch your next image to use, and then insert the new source url into your image tag on the page.
Alternatively, your iframe banner page could contain some images on it, and some javascript to rotate between the predefined images.
However, without knowing a more complete issue, that's the best answer I can give.
I have a hyperlink that in certain cases I want to change to show a jquery popup, but I'm having a strange problem when doing it on a master page. The following works in a regular page:
hyp1.NavigateUrl = "#notificationPopup";
Which renders as:
<a id="ctl00_hyp1" href="#notificationPopup">Example</a>
This is exactly what I want. The problem is with the exact same code on a hyperlink on the master page it renders as:
<a id="ctl00_hyp1" href="../MasterPages/#notificationPopup">Example</a>
It looks like it might be running the navigateUrl through ResolveClientUrl() or something when I'm setting it on the master page. I've tried swapping the <asp:hyperlink for a <a href runat=server, but the same thing happens.
Any ideas?
There is a note on MSDN Control.ResolveClientUrl method description.
The URL returned by this method is
relative to the folder containing the
source file in which the control is
instantiated. Controls that inherit
this property, such as UserControl and
MasterPage, will return a fully
qualified URL relative to the control.
So the behavior of master page in your exampe is fully predictable (although this is not a very comfortable to work with). So what are the alternatives?
The best one is to set the <a> as a client control (remove runat="server"); should work like a charm even in a master page:
Example
In the case if this control should be server side only: you could just build an URL from your code behind by using UriBuilder class:
UriBuilder newPath = new UriBuilder(Request.Url);
// this will add a #notificationPopup fragment to the current URL
newPath.Fragment = "notificationPopup";
hyp1.HRef = newPath.Uri.ToString();
Create a hidden field on your form and set the value to where you want to navigate / the url of the hyperlink instead of the hyperlinks navigate url. Then call the onclick method of the hyperlink in javascript and set the hyperlink there before the browser does the actual navigation.
<html><head><title></title></head>
<script type="text/javascript">
function navHyperlink(field)
{
field.href = document.getElementById('ctl00_hdnHypNav').value;
return true;
}
</script>
<input type="hidden" id="hdnHypNav" value="test2.html" runat="server"/>
<a href="" onclick="navHyperlink(this);" >click here</a>
</html>
Code behind would be:
hdnHypNav.value = "#notificationPopup";
You could also just try setting the url after the postback with below code, i.e. replace your code behind line with this one but I am not sure if it will work...
ScriptManager.RegisterStartupScript(this,this.GetType(),"SetHyp","$('ctl00_hyp1').href = '#notificationPopup';",True)
I found another way to solve the problem.
hyp1.Attributes.Add("href", "#notificationPopup");
Seeing as the whole reason I replaced my static hyperlink with a runat="server" one was to benefit from automatic resource-based localization, none of these answers served my needs.
My fix was to enclose the hyperlink in a literal:
<asp:Literal ID="lit1" runat="server" meta:resourcekey="lit1">
Example
</asp:Literal>
The downside is if you need to programmatically manipulate the link, it's a bit more annoying:
lit1.Text = String.Format("Example", HttpUtility.HtmlAttributeEncode(url));
I'm using literal to implement css, so as to have the css class vary depending on the page I'm on, the css being applied to some "a" tags also.
That bit (variable css on a tags) seems to be working for me at present for some reason, but the code breaks the use of the ~/ within links...
Does anyone know if there any consequences of using the below but limiting my pages to the root folder - as it does seem to be working there at least:
<li>
<a <asp:Literal id="ClassToUse" runat="server"/> id="home_link"
href= "Default.aspx" title="Home" onfocus="this.blur();" runat="server">Home</a>
</li>
Or if it is possible to get the path from root (~/) working within it, so as to enable a better folder layout/hierarchy.
I don't have an Openid and have given up on trying to sign in - for a while.
A few alternatives come to my mind:
Use a <asp:Hyperlink> and set CssClass property of the hyperlink instead of setting the value of the ClassToUse literal.
Fix the CSS class name of the link but change the CSS definitions by putting the <style> section on your page into a changeable literal.
But it's also possible that I misunderstood your question...
Thanks for the help Heinzi - this one got both working together for me... Went "You beauty" when it worked :)
<li><asp:Hyperlink id="ClassToUse" runat="server" NavigateUrl="~/Default.aspx" title="Home" onfocus="this.blur();">Home</asp:Hyperlink></li>
Case "Default.aspx"
' switch the background pics for the li
ClassToUse.CssClass = "active"