How can I, using the Sharepoint object model, get the URL to an image placed in the mapped images folder?
(added) I am deploying the image as part of a Visual Web Part (named ProgressWebPart for my site).
You should use the server relative url for static images:
/_layouts/images/ProgressWebPart/myImage.png
While the site relative url (no leading slash) will work, consider what happens when your web part is used in two separate sites. A user visiting these two sites would request the following images:
http://server/site1/_layouts/images/ProgressWebPart/myImage.png
http://server/site2/_layouts/images/ProgressWebPart/myImage.png
Even though both requests return the exact same file, the browser considers them distinct because they have different urls. By using the server relative url, you ensure that the user only downloads the static file once. If they visit other sites which use your web part then the browser will use the copy inside it's cache saving both time and bandwidth.
You don't need to use the OM to get this - its static and determined how your solution is packaged.
For an example - the default site logo for SharePoint 2010 will be here
_layouts/images/siteIcon.png
So http://yoursite/_layouts/images/siteIcon.png
and htp://yoursite/yoursite/yoursubsite/_layouts/images/siteIcon.png
It turns out to be (for my 'ProgressWebPart'): "_layouts/images/ProgressWebPart/"
As such, loading a PNG file into an Image control can be done in C# with:
Image image = new Image();
image.ImageUrl = "_layouts/images/ProgressWebPart/myImage.png";
Related
How does an img tag works on browser?
If I have set src property to some image hosted online, and I use that in my app. Then from what I know is our app will download the image from that url and render it inside our application. But I'm confused about how will the load distribution be? What part of load will come on our server(say we are fetching that url from an API) and what will come on the url's server?
I'm actually using google's photo api(which returns url of the image hosted on their server) to render the images on my webpage.
So the download would be from their server but say if the image size is 4mb then will our network call also download 4mb since in the end the image is on our html
One of the big innovations of when the World Wide Web was first invented, was that it combined two concepts:
The identity/name of a thing (like a document or image)
The instructions on how to find it
And it packs those in a URL. So the great thing about browsers was that you no longer needed tell it what server to connect to find the thing you want. The browser just looks at a URL, and will connect to server with the name from the 'host' part of the URL, using the port in URL and protocol and retrieve the path.
So given:
<img src="http://example/image.jpg" />
The browser has everything it needs to find the image, and will do so without needing help from the server that rendered that image tag.
I have developed a SharePoint Web Part where I have an iframe that I need to load with several pages depend on different values.
For instance, I have this files
file1.html
file2.html
file3.html
And I need to pass the path of one of this elements to an iframe
Where can I put this files and How can I retrieve the right path of this pages?
Regards
Try to save the html files in a library and set the iframe url dynamically.
$('#iframeId').attr('src', url)
I'm new to web development and i want to ask that why some website have the "/"?
for example https://www.roblox.com/home, notice the "/home" what does that called
I have tried to search on google and i can't find the answer
And some website have like "/login.php", "/index.html" it can also be html?
These are URLs (https://en.wikipedia.org/wiki/URL) and they identify the resource you are trying to reach. I would suggest reading more about how web pages works to get a better general overview of things(e.g.: https://developer.mozilla.org/en-US/docs/Learn/Getting_started_with_the_web/How_the_Web_works)
How these resources are actually interpreted depends on the server side implementation:
.php are usually processed by PHP web server
Other static files such as images (*.png , *.jpg, etc), html files, svgs, CSS, js, etc - Are usually located in the local server by the web server (httpd, tomcat, IIS, nodejs, and many many others) and the files as transmitted to the client 'as-is'
When using online tools to build websites, these complexities are usually abstracted away, and in the end URLs will just mean a resource identifier.
[domain]/[section]/[page(.html|.php)|resource(.js|.css)]
domain: the address of the website
section: a way to navigate inside the website itself
page: the user interface that might be rendered server side of client side hold the controls shown to user
resource: files that changes how the content in the pages looks and behaves like
I would like to create the following scenario in my web project, but as I am not pro web developer I don't know how to handle this.
Let's assume that I have project with main domain:
http://foobar.com and on this I have a links to the following subdomains:
http://xx.foobar.com
http://yy.foobar.com
I would like to that every site hosted on subdomains used the same code with only one different parameter sent to the subdomain from main page. This parameter will be a JavaScript variable. I am using Azure Web Sites from my project. The main question here is how to manage the code (now I am using Continuos Integration with GitHub) through these subdomains (the source code for every subdomain would be the same, except this one variable). Where should I start to search / read?
Are you passing any value for the parameter? Or is it just a static parameter? If it's static, you could possibly use JavaScript code to read the subdomain name in the URL.
Not sure what language you're using on the server, but you should also able to read the subdomain via server-side code.
But if its value is dynamic, the main page with the links can generate a QueryString parameter to pass along in the URL. Your implantation will vary depending on what language you've selected.
UPDATED, with additional info:
When you say "share the project source code between subdomains", do you mean that you want to deploy the same web app to multiple endpoints?
If so, you can create a separate Web App in Azure (formerly known as Azure Web Site) for each corresponding subdomain, and set up your source control to deploy to both of them whenever you check in your code.
References:
https://azure.microsoft.com/en-us/documentation/articles/web-sites-deploy/
https://azure.microsoft.com/en-us/documentation/articles/web-sites-publish-source-control/
Since you have no server-side code, I'm using you have only HTML/JavaScript/CSS files. So, you can write JavaScript code to read the parameter from the URL.
References:
http://www.w3schools.com/jsref/prop_loc_href.asp
http://www.w3schools.com/jsref/prop_loc_pathname.asp
http://www.cssmojo.com/the_location_object/
As I mentioned earler, you would set up the links on the main index page to pass in QueryString parameters:
e.g.
Link 1: http://sub1.mywebsite.com/?param1
Link 2: http://sub2.mywebsite.com/?param2
Hope that helps!
First, make sure you point your domain to your azure website using wildcard (references)
Second, in your html head, find the subdomain using javascript and assign in to the variable you want to use
var full_url = window.location.host; // e.g. subdomain.host.com
var parts = full.split('.'); // split it
var subdomain = parts[0];
now you can use the subdomain variable to change your website based on subdomain value (e.g. change the content)
HI
I have the following (apparently simple) problem: I have to install a simple website, made by someone else, on a web hosting account. The site consists of lot and lot of HTML pages, no dynamic content, created some in MS Word and saved as html, some in frontpage, etc. A mixed bag.
I uploaded initially on a test account on my server (Win Server 2003) and it works ok.
Then I uploaded on the real web hosting (fedora / apache).
When I loaded the site in browser I see lot of odd craracters (instead of diacritics, used in html pages). Duacritics were saved as escape code, like & #350; for Ș (using codepage 1252).
The problem is, when I load the page from my own test server, the browser select automatically correct codepage (1252).
But when I load the site from public host, the same bowser loads the page using utf-8 encoding, rendering page with odd caracrets.
The test site on my server can be seen at http://radu-stanian.dnsalias.com and on public server at http://radustanian.scoli.edu.ro/
This happens no matter what browser I use (IE, ff or chrome)
What should I do to force browsers to load the pages in correct codepage?
Making changes to every page is not an option, because there are hundreds of pages, created by various peoples which could edit them further for update
Thank you
I did a quick google search and this is what I came up with:
http://www.w3.org/International/questions/qa-htaccess-charset
I've never messed with the .htaccess files with this scenario, but from what I read up it seems like you can force a certain character codepage mode based on file extension, which is what you need.
I'm not sure if it works, but hopefully it does :)
Most web servers allow you to edit HTTP headers. One of them can specify the exact codepage for a browser to use.
For example:
Content-Type: text/html; charset=ISO-8859-4