Search Results

Search found 2033 results on 82 pages for 'absolute'.

Page 16/82 | < Previous Page | 12 13 14 15 16 17 18 19 20 21 22 23  | Next Page >

  • Center four columns in CSS

    - by Ernest
    Hi everybody, I'm trying to make four columns that are centered on the frontpage. I would like it to look like this example: http://www.clutterpad.com/ My code looks like this: #bottom-container {width:100%;height:250px;position:relative;} #bottom-mid {background-color:white;} #bottom-left, #bottom-mid, #bottom-right {height:250px;} #bottom-left, #bottom-right {width:50%;float:left;} #bottom-left {background-color:white;position:absolute;top:0px;left:0px;} #bottom-right {background-color:white;position:absolute;top:0px;left:50%;} #bottom-mid {position:relative;margin:0px auto; width:1000px;z-index:2;} #column-container {width:100%; margin:20px auto;} .column {width:200px;float:left;font-size:10pt;font-family:Arial;margin:20px 10px;} But it's not working out. How should I code it to look like the example I mentioned before?

    Read the article

  • CSS - how to dry up?

    - by keruilin
    Is there a way to DRY this CSS up? Only difference is color? div.base-text-gold { position: absolute; bottom: 9px; color: #FED577; font-size: 10px; font-weight: bolder; text-align: center; width: 61px; text-transform: uppercase; } div.base-text-grey { position: absolute; bottom: 9px; color: #D1D2D4; font-size: 10px; font-weight: bolder; text-align: center; width: 61px; text-transform: uppercase; }

    Read the article

  • How get file path from std::ifstream in c++

    - by Nilesh Shinge
    Hi All I am opening file using C++ function std::ifstream. I may open file using relative path (file.txt) or absoulte path (C:\test\file.txt). As I am passing string as file name, dont know whether it is relative or absolute path. Can any body tell me how to get absolutre path after file has been successfully open using std::ifstream function. e.g. std::ifstream file(strFile); // strFile = "file.txt" or strFile = "C:\test\file.txt" I want absolute path after file open successfully. Thanks Nilesh

    Read the article

  • Plone, behaviour of URLs

    - by jpet
    The situation is the following: I created a site with Plone, developed, used, but behind a test URL. Now it has to be published, but the test URL is not appropriate and I don't want to move the site. I think, if I use a redirect, it won't be appear in the URL-bar, only in the case of site start page. Am I wrong? (The test URL should not be used, because it will be a "semi-official" site.) What do you suggest to do? As far as I can see Plone uses absolute URLs everywhere. I can add relative URLs, but if I create a new page, a new event, etc., then they have absolute URLs on other automatically generated inner pages. Is there any way to convert these URLs to relative paths? Is there any setting possibilty where only a checkbox changes this default setting?

    Read the article

  • Cannot position Google +1 button with CSS?

    - by Bogdan Protsenko
    I'm having some trouble positioning the Google +1 button on my website. The div is as follows: <div class="g-plusone"></div> The CSS I'm using is pretty simple: .g-plusone { position: absolute; top:95px; left:715px; } I know for a fact that the div in question is being accessed. What's strange is that other social sharing buttons, such as the FB like below follow the same syntax and are positioned perfectly. .fb-like { position: absolute; top:62px; left:715px; } Any ideas?

    Read the article

  • Strange CSS Positioning issue with a fader on a responsive site

    - by EPICWebDesign
    I'm developing a prototype responsive wordpress theme version of my homepage. I'm running into issues with the fader on the homepage. http://dev.epicwebdesign.ca/epicblog/ When the image switches, it uses position:absolute to overlay the pictures, then goes back to position:relative. I need to make the absolute be relative to the bottom left corner of the menu instead of the top left corner of #wrap so it doesn't overlap. I tried putting it in a container div like this: http://wiki.orbeon.com/forms/doc/contributor-guide/browser#TOC-Absolutely-positioned-box-inside-a-box-with-overflow:-auto-or-hidden but that doesn't seem to work. Any ideas? There are major CSS compatibility issues in IE, try it in chrome. It should look similar to http://epicwebdesign.ca. When the browser window is shrunk horizontially, the whole theme compensates.

    Read the article

  • Making a jQuery selection in IE on html added via .load()

    - by Joel Crawford-Smith
    Scenario: I am using jQuery to lazy load some html and change the relative href attributes of all the anchors to absolute links. The loading function adds the html in all browsers. The url rewrite function works on the original DOM in all browsers. But In IE7, IE8 I can't run that same function on the new lazy loaded html in the DOM. //lazy load a part of a file $(document).ready(function() { $('#tab1-cont') .load('/web_Content.htm #tab1-cont'); return false; }); //convert relative links to absolute links $("#tab1-cont a[href^=/]").each(function() { var hrefValue = $(this).attr("href"); $(this) .attr("href", "http://www.web.org" + hrefValue) .css('border', 'solid 1px green'); return false; }); I think my question is: whats the trick to getting IE to make selections on DOM that is lazy loaded with jQuery? This is my first post. Be gentle :-) Thanks, Joel

    Read the article

  • ModalPopupExtender doesn't work on IE6 frame layout

    - by Joe
    I'm using a "frame" layout similar to the one in this excellent answer: a div #top at the top of the page, a div#left on the left, and a div #main with the main content. The #top and #left divs contain navigation menus. Now I want to use a popup div using the AjaxControlToolkit ModalPopupExtender inside the content (#main) div. This works fine on IE8 (where #top, #left, #main all have position:fixed), but when I run it on IE6, the modal background only covers the #main div - I need it to cover the whole of the page including the #top and #left navigation divs. Looking at the script for ModalPopupExtender, it appears to be searching up the parent hierarchy until it finds a parent with position relative or absolute. And in the IE6 rendering, the #main div has position:absolute because position:fixed is not supported, which I guess explains what is happening. Any suggestions for the best/easiest way to get this working properly on IE6? Ideally without modifying the ModalPopupExtender code, but I'll do this if I have to and it's the best solution.

    Read the article

  • Making a row of divs all be the same height using CSS

    - by pavel
    I have a row of divs that must all be the same height, but I have no way of knowing what that height might be ahead of time (the content comes from an external source). I initially tried placing the divs in an enclosing div and floated them left. I then set their height to be "100%", but this had no perceptible effect. By setting the height on the enclosing div to a fixed-height I could then get the floated divs to expand, but only up to the fixed height of the container. When the content in one of the divs exceeded the fixed height, it spilled over; the floated divs refused to expand. I Googled this floated-divs-of-the-same-height problem and apparently there's no way to do it using CSS. So now I am trying to use a combination of relative and absolute positioning instead of floats. This is the CSS: <style type="text/css"> div.container { background: #ccc; position: relative; min-height: 10em; } div.a { background-color: #aaa; position: absolute; top: 0px; left: 0px; bottom: 0px; width: 40%; } div.b { background-color: #bbb; position: absolute; top: 0px; left: 41%; bottom: 0px; width: 40%; } </style> This is a simplified version of the HTML: <div class="container"> <div class="a">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Integer pretium dui sit amet felis. Integer sit amet diam. Phasellus ultrices viverra velit.</div> <div class="b">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Integer pretium dui sit amet felis. Integer sit amet diam. Phasellus ultrices viverra velit. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Integer pretium dui sit amet felis. Integer sit amet diam. Phasellus ultrices viverra velit.</div> </div> This works, unless you change the min-height to something like 5em (demonstranting what happens when the content exceeds the minimum height), and you can see that while the text doesn't get cutoff, the divs still refuse to expand. Now I am at a lose. Is there any way to do this using CSS?

    Read the article

  • Stretching DIV to 100% height and width of window but not less than 800x600px

    - by El Eme
    I have a page that needs to stretch and resize with with window and I've managed to do that but I need that the "inner div" (#pgContent) stretch if the window is resized to higher dimensions but that it doesn't shrink more than, let's say for example 800 x 600 px. As I have it now it stretches well but it also shrinks more than I want! It's working as I want in width but not in height!? Here's a visual example: My CSS: * { margin: 0; padding: 0; outline: 0; } /*| PAGE LAYOUT |*/ html, body { height: 100%; width: 100%; /*text-align: center;*/ /*IE doesn't ~like this*/ cursor: default; } #pgWrapper { z-index: 1; min-height: 100%; height: auto !important; /*min-height: 600px;*/ /* THIS SHOULD WORK BUT IT DOESN'T */ height: 100%; min-width: 1000px; width: 100%; position: absolute; overflow: hidden; text-align: center; background: #000; } #pgContent { position: absolute; top: 30px; left: 30px; right: 30px; bottom: 50px; overflow: hidden; background: #CCC; } #footWrapper { z-index: 2; height: 50px; min-width: 940px; position: absolute; left: 30px; right: 30px; bottom: 0px; background: #C00; } /*| END PAGE LAYOUT |*/ And the HTML: <body> <div id="pgWrapper"> <div id="pgContent"> This DIV should stretch with window but never lower than for example 800px x 600px!<br /> If window size is lower then scrollbars should appear. </div> </div> <div id="footWrapper"> <div id="footLft"></div> <div id="footRgt"></div> </div> </body> If someone could give me a help on this I would appreciate. Thanks in advance.

    Read the article

  • Firefox can not layout nested tables properly?

    - by ooplidi
    I want to implement a collapsible menu. I plan to use table component to simulate a menu, and nest a sub table into a table cell to simulate a sub menu. Below is my code, it works as expected in IE, Chrome and Safari, but it doesn't work well in Firefox: <html> <body> <div id="menu" style="position:absolute; left:150px; top:100px; z-index:1"> <table width="200px" height="90" border=1 cellpadding="0" cellspacing="0"> <tr> <td colspan=2>Money</td> </tr> <tr> <td colspan=2>Tool</td> </tr> <tr> <td>Food <table style="position:absolute; left:200px; top:60px; z-index:1" width="200px" height="60px" border="1" cellpadding="0" cellspacing="0"> <tr> <td>Cookie</td> </tr> <tr> <td>Fruit <table style="position:absolute; left:200px; top:30px; z-index:1" width="200px" height="60px" border="1" cellpadding="0" cellspacing="0"> <tr> <td>Apple</td> </tr> <tr> <td>Banana</td> </tr> </table> </td> </tr> </table> </td> </tr> </table> </div> </body> </html> It seems that Firefox think the "left" and "top" attribute for the level 3 menu is relative to the level 1 menu, so it layout the level 3 menu incorrectly. Other browsers will calculate the offset base on the level 2 menu, that works as expected. Is it a bug in Firefox? If so how can I work around it? I want my code to have the same behavior in all major browsers.

    Read the article

  • background semitransparent div

    - by plasticrabbit
    I want to show some dialog (absolute positioned div), and I want to show it above semitransparent 100% div, so everything on background will be dimmed. I have managed it by <div class='transpBox'></div> .transparentBox { position: absolute; top: 0px; left: 0px; width: 100%; height: 100%; background-color: #white; opacity: 0.9; z-index: 499; } This is all right, but when dialog height is more than browser height and you scroll down, you see that transparent div is not in full screen. What is proper way to make such thing?

    Read the article

  • CSS Position Help (horizontal sidebar showing up when animate content over)

    - by jstacks
    Let me try my best to explain what I'd like to have happen, show you the code I have an hopefully I can get some help. So, I'm trying to do a sliding navigation UI from the left side of the screen (like a lot of mobile apps). The main content slides over, displaying the navigation menu beneath. Right now the browser thinks the screen is getting wider and introduces a horizontal scroll bar. However, I don't want that to happen... How do I get the div to animate off screen but not enlarge the width of the screen (i.e. keep it partially off screen)? Anyway here is my fiddle: http://jsfiddle.net/2vP67/6/ And here is the code within the post: HTML <div id='wrapper'> <div id='navWide'> </div> <div id='containerWide'> </div> <div id='containerTall'> <div id='container'> <div id='nav'> <div id='navNavigate'> Open Menu </div> <div id='navNavigateHide'> Close Menu </div> </div> </div> </div> <div id='sideContainerTall'> <div id='sideContainer'> <div id='sideNav'>Side Navigation </div> </div> </div> </div> CSS #wrapper { width:100%; min-width:1000px; height:100%; min-height:100%; position:relative; top:0; left:0; z-index:0; } #navWide { color: #ffffff; background:#222222; width:100%; min-width:1000px; height:45px; position:fixed; top:0; left:0; z-index:100; } #containerWide { width:100%; min-width:1000px; min-height:100%; position:absolute; top:45px; z-index:100; } #containerTall { color: #000000; background:#dadada; width:960px; min-height:100%; margin-left:-480px; position:absolute; top:0; left:50%; z-index:1000; } /***** main container *****/ #container { width:960px; min-height:585px; } #nav { color: #ffffff; background:#222222; width:960px; height:45px; position:fixed; top:0; z-index:10000; } #navNavigate { background:yellow; font-size:10px; color:#888888; width:32px; height:32px; padding:7px 6px 6px 6px; float:left; cursor:pointer; } #navNavigateHide { background:yellow; font-size:10px; color:#888888; width:32px; height:32px; padding:7px 6px 6px 6px; float:left; cursor:pointer; display:none; } #sideContainerTall { background:#888888; width:264px; min-height:100%; margin-left:-480px; position:absolute; top:0; left:50%; z-index:500; } #sideContainer { width:264px; min-height:585px; display:none; } #sideContainerTall { background:#888888; width:264px; min-height:100%; margin-left:-480px; position:absolute; top:0; left:50%; z-index:500; } #sideContainer { width:264px; min-height:585px; display:none; } #sideNav { width:264px; height:648px; float:left; } Javascript $(document).ready(function() { $('div#navNavigate').click(function() { $('div#navNavigate').hide(); $('div#navNavigateHide').show(); $('div#sideContainer').show(); $('div#containerTall').animate({ 'left': '+=264px' }); }); $('div#navNavigateHide').click(function() { $('div#navNavigate').show(); $('div#navNavigateHide').hide(); $('div#containerTall').animate({ 'left': '-=264px' }, function() { $('div#sideContainer').hide(); }); }); });

    Read the article

  • Java - Loading dlls by a relative path and hide them inside a jar

    - by supertreta
    Hi guys, I am developing a Java application that should be release as a jar. This program depends on c++ external libraries called by JNI. To load them, I use the method System.load with an absolute path and this works fine. However, I really want to "hide" them inside the jar, so I have created a package to collect them. This forces me to load an relative path - the package path. By this approach, I let the user run the jar in any directory, without being worried about linking the dll's or bored with a previous installation process. This throws the expected exception: Exception in thread "main" java.lang.UnsatisfiedLinkError: Expecting an absolute path of the library How can I get this working? Thanks for your help!

    Read the article

  • scrollTop with jQuery

    - by Narcís
    I want a foot to be at the bottom of the page. But when the user makes the window smaller, the two divs come together, it would be better that begins the scroll and hides the foot. I don't know if I explain? I have the code life here: http://jsfiddle.net/mdAsn/ $(function(){ $(document).scroll(function(){ var topDistance = $('#foot').scrollTop(); if(topDistance >= 420){ $('#foot').css({position: 'absolute',bottom:'10px'}); } else{ $('#foot').css({position: 'absolute',top:'410px'}); } }); })

    Read the article

  • dynamic element positioning

    - by Ahmet vardar
    Hi, I have been seeing this thing for months and years and i really wanna know how to do that one. For example, there is an element in the middle of the page. and it is in absolute position. When scroll downs and comes to that element, it becomes fixed positioned and follows the scroll, when scroll up and back to middle of the page it becomes absolute again. I can give google adwords accounts page as an example, in the campaigns page, your keywords' header is the same thing. how to do that one ? thanks

    Read the article

  • ASP.Net aspx markup

    - by Batuta
    I am working on some old web forms application. When I changed from design to view source of the aspx page, the aspx markup becomes disarranged. For example, a label is written as follows: <asp:label id="Label20" style="Z-INDEX: 119; LEFT: 16px; POSITION: absolute; TOP: 424px" runat="server" Height="24px" Width="72px">Instructions:</asp:label> It suddenly becomes like this (when I toggle from design to source) <asp:label id="Label20" style="Z-INDEX: 119; LEFT: 16px; POSITION: absolute; TOP: 424px" runat="server" Height="24px" Width="72px">Instructions:</asp:label> Notice that the alignment and margins, tab stops are changed. Any idea how to prevent VS from doing this? Thanks.

    Read the article

  • Integrating HTML into Silverlight Applications

    - by dwahlin
    Looking for a way to display HTML content within a Silverlight application? If you haven’t tried doing that before it can be challenging at first until you know a few tricks of the trade.  Being able to display HTML is especially handy when you’re required to display RSS feeds (with embedded HTML), SQL Server Reporting Services reports, PDF files (not actually HTML – but the techniques discussed will work), or other HTML content.  In this post I'll discuss three options for displaying HTML content in Silverlight applications and describe how my company is using these techniques in client applications. Displaying HTML Overlays If you need to display HTML over a Silverlight application (such as an RSS feed containing HTML data in it) you’ll need to set the Silverlight control’s windowless parameter to true. This can be done using the object tag as shown next: <object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%"> <param name="source" value="ClientBin/HTMLAndSilverlight.xap"/> <param name="onError" value="onSilverlightError" /> <param name="background" value="white" /> <param name="minRuntimeVersion" value="4.0.50401.0" /> <param name="autoUpgrade" value="true" /> <param name="windowless" value="true" /> <a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.50401.0" style="text-decoration:none"> <img src="http://go.microsoft.com/fwlink/?LinkId=161376" alt="Get Microsoft Silverlight" style="border-style:none"/> </a> </object> By setting the control to “windowless” you can overlay HTML objects by using absolute positioning and other CSS techniques. Keep in mind that on Windows machines the windowless setting can result in a performance hit when complex animations or HD video are running since the plug-in content is displayed directly by the browser window. It goes without saying that you should only set windowless to true when you really need the functionality it offers. For example, if I want to display my blog’s RSS content on top of a Silverlight application I could set windowless to true and create a user control that grabbed the content and output it using a DataList control: <style type="text/css"> a {text-decoration:none;font-weight:bold;font-size:14pt;} </style> <div style="margin-top:10px; margin-left:10px;margin-right:5px;"> <asp:DataList ID="RSSDataList" runat="server" DataSourceID="RSSDataSource"> <ItemTemplate> <a href='<%# XPath("link") %>'><%# XPath("title") %></a> <br /> <%# XPath("description") %> <br /> </ItemTemplate> </asp:DataList> <asp:XmlDataSource ID="RSSDataSource" DataFile="http://weblogs.asp.net/dwahlin/rss.aspx" XPath="rss/channel/item" CacheDuration="60" runat="server" /> </div> The user control can then be placed in the page hosting the Silverlight control as shown below. This example adds a Close button, additional content to display in the overlay window and the HTML generated from the user control. <div id="RSSDiv"> <div style="background-color:#484848;border:1px solid black;height:35px;width:100%;"> <img alt="Close Button" align="right" src="Images/Close.png" onclick="HideOverlay();" style="cursor:pointer;" /> </div> <div style="overflow:auto;width:800px;height:565px;"> <div style="float:left;width:100px;height:103px;margin-left:10px;margin-top:5px;"> <img src="http://weblogs.asp.net/blogs/dwahlin/dan2008.jpg" style="border:1px solid Gray" /> </div> <div style="float:left;width:300px;height:103px;margin-top:5px;"> <a href="http://weblogs.asp.net/dwahlin" style="margin-left:10px;font-size:20pt;">Dan Wahlin's Blog</a> </div> <br /><br /><br /> <div style="clear:both;margin-top:20px;"> <uc:BlogRoller ID="BlogRoller" runat="server" /> </div> </div> </div> Of course, we wouldn’t want the RSS HTML content to be shown until requested. Once it’s requested the absolute position of where it should show above the Silverlight control can be set using standard CSS styles. The following ID selector named #RSSDiv handles hiding the overlay div shown above and determines where it will be display on the screen. #RSSDiv { background-color:White; position:absolute; top:100px; left:300px; width:800px; height:600px; border:1px solid black; display:none; } Now that the HTML content to display above the Silverlight control is set, how can we show it as a user clicks a HyperlinkButton or other control in the application? Fortunately, Silverlight provides an excellent HTML bridge that allows direct access to content hosted within a page. The following code shows two JavaScript functions that can be called from Siverlight to handle showing or hiding HTML overlay content. The two functions rely on jQuery (http://www.jQuery.com) to make it easy to select HTML objects and manipulate their properties: function ShowOverlay() { rssDiv.css('display', 'block'); } function HideOverlay() { rssDiv.css('display', 'none'); } Calling the ShowOverlay function is as simple as adding the following code into the Silverlight application within a button’s Click event handler: private void OverlayHyperlinkButton_Click(object sender, RoutedEventArgs e) { HtmlPage.Window.Invoke("ShowOverlay"); } The result of setting the Silverlight control’s windowless parameter to true and showing the HTML overlay content is shown in the following screenshot:   Thinking Outside the Box to Show HTML Content Setting the windowless parameter to true may not be a viable option for some Silverlight applications or you may simply want to go about showing HTML content a different way. The next technique I’ll show takes advantage of simple HTML, CSS and JavaScript code to handle showing HTML content while a Silverlight application is running in the browser. Keep in mind that with Silverlight’s HTML bridge feature you can always pop-up HTML content in a new browser window using code similar to the following: System.Windows.Browser.HtmlPage.Window.Navigate( new Uri("http://silverlight.net"), "_blank"); For this example I’ll demonstrate how to hide the Silverlight application while maximizing a container div containing the HTML content to show. This allows HTML content to take up the full screen area of the browser without having to set windowless to true and when done right can make the user feel like they never left the Silverlight application. The following HTML shows several div elements that are used to display HTML within the same browser window as the Silverlight application: <div id="JobPlanDiv"> <div style="vertical-align:middle"> <img alt="Close Button" align="right" src="Images/Close.png" onclick="HideJobPlanIFrame();" style="cursor:pointer;" /> </div> <div id="JobPlan_IFrame_Container" style="height:95%;width:100%;margin-top:37px;"></div> </div> The JobPlanDiv element acts as a container for two other divs that handle showing a close button and hosting an iframe that will be added dynamically at runtime. JobPlanDiv isn’t visible when the Silverlight application loads due to the following ID selector added into the page: #JobPlanDiv { position:absolute; background-color:#484848; overflow:hidden; left:0; top:0; height:100%; width:100%; display:none; } When the HTML content needs to be shown or hidden the JavaScript functions shown next can be used: var jobPlanIFrameID = 'JobPlan_IFrame'; var slHost = null; var jobPlanContainer = null; var jobPlanIFrameContainer = null; var rssDiv = null; $(document).ready(function () { slHost = $('#silverlightControlHost'); jobPlanContainer = $('#JobPlanDiv'); jobPlanIFrameContainer = $('#JobPlan_IFrame_Container'); rssDiv = $('#RSSDiv'); }); function ShowJobPlanIFrame(url) { jobPlanContainer.css('display', 'block'); $('<iframe id="' + jobPlanIFrameID + '" src="' + url + '" style="height:100%;width:100%;" />') .appendTo(jobPlanIFrameContainer); slHost.css('width', '0%'); } function HideJobPlanIFrame() { jobPlanContainer.css('display', 'none'); $('#' + jobPlanIFrameID).remove(); slHost.css('width', '100%'); } ShowJobPlanIFrame() handles showing the JobPlanDiv div and adding an iframe into it dynamically. Once JobPlanDiv is shown, the Silverlight control host has its width set to a value of 0% to allow the control to stay alive while making it invisible to the user. I found that this technique works better across multiple browsers as opposed to manipulating the Silverlight control host div’s display or visibility properties. Now that you’ve seen the code to handle showing and hiding the HTML content area, let’s switch focus to the Silverlight application. As a user clicks on a link such as “View Report” the ShowJobPlanIFrame() JavaScript function needs to be called. The following code handles that task: private void ReportHyperlinkButton_Click(object sender, RoutedEventArgs e) { ShowBrowser(_BaseUrl + "/Report.aspx"); } public void ShowBrowser(string url) { HtmlPage.Window.Invoke("ShowJobPlanIFrame", url); } Any URL can be passed into the ShowBrowser() method which handles invoking the JavaScript function. This includes standard web pages or even PDF files. We’ve used this technique frequently with our SmartPrint control (http://www.smartwebcontrols.com) which converts Silverlight screens into PDF documents and displays them. Here’s an example of the content generated:   Silverlight 4’s WebBrowser Control Both techniques shown to this point work well when Silverlight is running in-browser but not so well when it’s running out-of-browser since there’s no host page that you can access using the HTML bridge. Fortunately, Silverlight 4 provides a WebBrowser control that can be used to perform the same functionality quite easily. We’re currently using it in client applications to display PDF documents, SSRS reports and standard HTML content. Using the WebBrowser control simplifies the application quite a bit since no JavaScript is required if the application only runs out-of-browser. Here’s a simple example of defining the WebBrowser control in XAML. I typically define it in MainPage.xaml when a Silverlight Navigation template is used to create the project so that I can re-use the functionality across multiple screens. <Grid x:Name="WebBrowserGrid" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Visibility="Collapsed"> <StackPanel HorizontalAlignment="Stretch" VerticalAlignment="Stretch"> <Border Background="#484848" HorizontalAlignment="Stretch" Height="40"> <Image x:Name="WebBrowserImage" Width="100" Height="33" Cursor="Hand" HorizontalAlignment="Right" Source="/HTMLAndSilverlight;component/Assets/Images/Close.png" MouseLeftButtonDown="WebBrowserImage_MouseLeftButtonDown" /> </Border> <WebBrowser x:Name="JobPlanReportWebBrowser" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" /> </StackPanel> </Grid> Looking through the XAML you can see that a close image is defined along with the WebBrowser control. Because the URL that the WebBrowser should navigate to isn’t known at design time no value is assigned to the control’s Source property. If the XAML shown above is left “as is” you’ll find that any HTML content assigned to the WebBrowser doesn’t display properly. This is due to no height or width being set on the control. To handle this issue the following code is added into the XAML’s code-behind file to dynamically determine the height and width of the page and assign it to the WebBrowser. This is done by handling the SizeChanged event. void MainPage_SizeChanged(object sender, SizeChangedEventArgs e) { WebBrowserGrid.Height = JobPlanReportWebBrowser.Height = ActualHeight; WebBrowserGrid.Width = JobPlanReportWebBrowser.Width = ActualWidth; } When the user wants to view HTML content they click a button which executes the code shown in next: public void ShowBrowser(string url) { if (Application.Current.IsRunningOutOfBrowser) { JobPlanReportWebBrowser.NavigateToString("<html><body><iframe src='" + url + "' style='width:100%;height:97%;' /></body></html>"); WebBrowserGrid.Visibility = Visibility.Visible; } else { HtmlPage.Window.Invoke("ShowJobPlanIFrame", url); } } private void WebBrowserImage_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { WebBrowserGrid.Visibility = Visibility.Collapsed; }   Looking through the code you’ll see that it checks to see if the Silverlight application is running out-of-browser and then either displays the WebBrowser control or runs the JavaScript function discussed earlier. Although the WebBrowser control’s Source property could be assigned the URI of the page to navigate to, by assigning HTML content using the NavigateToString() method and adding an iframe, content can be shown from any site including cross-domain sites. This is especially handy when you need to grab a page from a reporting site that’s in a different domain than the Silverlight application. Here’s an example of viewing  PDF file inside of an out-of-browser application. The first image shows the application running out-of-browser before the user clicks a PDF HyperlinkButton.  The second image shows the PDF being displayed.   While there are certainly other techniques that can be used, the ones shown here have worked well for us in different applications and provide the ability to display HTML content in-browser or out-of-browser. Feel free to add a comment if you have another tip or trick you like to use when working with HTML content in Silverlight applications.   Download Code Sample   For more information about onsite, online and video training, mentoring and consulting solutions for .NET, SharePoint or Silverlight please visit http://www.thewahlingroup.com.

    Read the article

  • HTTP Headers: Max-Age vs Expires – Which One To Choose?

    - by Gopinath
    Caching of static content like images, scripts, styles on the client browser reduces load on the webservers and also improves end users browsing experience by loading web pages quickly. We can use HTTP headers Expires or Cache-Control:max-age to cache content on client browser and set expiry time for them. Expire header is HTTP/1.0 standard and Cache-Control:max-age is introduced in HTTP/1.1 specification to solve the issues and limitation with Expire  header. Consider the following headers.   Cache-Control: max-age=24560 Expires: Tue, 15 May 2012 06:17:00 GMT The first header instructs web browsers to cache the content for 24560 seconds relative to the time the content is downloaded and expire it after the time period elapses. The second header instructs web browser to expiry the content after 15th May 2011 06:17. Out of these two options which one to use – max-age or expires? I prefer max-age header for the following reasons As max-age  is a relative value and in most of the cases it makes sense to set relative expiry date rather than an absolute expiry date. Expire  header values are complex to set – time format should be proper, time zones should be appropriate. Even a small mistake in settings these values results in unexpected behaviour. As Expire header values are absolute, we need to  keep changing them at regular intervals. Lets say if we set 2011 June 1 as expiry date to all the image files of this blog, on 2011 June 2 we should modify the expiry date to something like 2012 Jan 1. This add burden of managing the Expire headers. Related: Amazon S3 Tips: Quickly Add/Modify HTTP Headers To All Files Recursively cc image flickr:rogue3w This article titled,HTTP Headers: Max-Age vs Expires – Which One To Choose?, was originally published at Tech Dreams. Grab our rss feed or fan us on Facebook to get updates from us.

    Read the article

< Previous Page | 12 13 14 15 16 17 18 19 20 21 22 23  | Next Page >