Im trying to add a light box which automatically opens up when someone visits my homepage. something similar to
http://directorsof.com/
any idea on how I can do this.
You can use for example colorbox to get a lightbox that opens after the page is loaded.
Download colorbox from here: http://colorpowered.com/colorbox/latest, extract the file and modify the index.html file in the example1 folder.
Replace:
$("a[rel='example1']").colorbox();
with
$("a[rel='example1']").colorbox({open:true});
Open the index.html file in your browser to see the lightbox coming up directly.
are you using a master page?You need to place 2 divs in your file. One that has a fixed position or absolute and dimmer the background, and another div that displays the content.
Check this link out, it is a web messagebox but it will do what you want using a template approach.
http://www.snippetbank.net/detail/snippetdetail/9-aspcsharp/3-filemanipulation/404-Web-MessageBox.html
You can add the following to your home page
window.onload = function() {
//Open your lightbox here
};
Or you can use Jquery all together with something like...
$(function(){
$(body).load(function(){
// Open your lightbox here
});
});
both of the above will fire the lightbox once the page is loaded. Its probably better to use the jquery example as this will ensure that the DOM is ready.
Related
I currently have a js file that gets loaded with a page.
Now that .js file has the following statement in it
$("#Click").on('click', function () {
__CHILD_WINDOW_HANDLE = window.open('MyPopUp.html', '_blank', 'width=700,height=500,left=200,top=100');
});
From the above statement when the user clicks on the "Click" button a child window (MyPopUp.html) should load up , however I get the error
The resource cannot be found.
My question is how do I specify the path of the html file ? The only way I am familiar with is through RouteConfig.cs in which Ill need to introduce another controller. Any suggestions on how I can accomplish this ?
I solved this issue by creating a separate controller and then having that controller return the html file. Also since I am using razor html files are not allowed so I had to return back a cshtml file.
I want to show a web page within another web web in asp.net. I have a page named home.aspx and a page name add.aspx how can i do this.
if you just want to load contenct than make use of jquery ajax function or noraml ajax to load data in you page
Example
$("#result").load("AjaxPages/Page.aspx", function () {
alert("Page.html has been loaded successfully!")
});
Use iframes. Pleace for example this code inside the homep.aspx. This is only the idea, find how to show it with out border and with out scrool bars, and also how to fit it in place.
<iframe src="add.aspx"></iframe>
http://www.w3schools.com/tags/tag_iframe.asp
http://htmlhelp.com/reference/html40/special/iframe.html
ajax and iframe
Use ajax if you have some informations only to show. Use iframe if you also need independend post backs that enters data.
ajax is better if you care to have only one page, not working with out javascript, and maybe you need to add more ajax to make more thinks with the data that you get.
iframe is fast, but 'dirty' because is not seo friendly, a user can open content from iframe alone, etc.
i have made a page in asp.net, i have a costing calculator which has more than 50 fields, dependent on each other, one is the result of previous two and like that, i want my page to be printed in a well manner, and the header of the page which is in master page should not be in print, also the color schemes i want to adjust, let me know the best solution for this which .net provides
Put the content inside <div id="divid">YOUR CONTENT NEEDS TO BE PRINTED</div>
Then call the javascript function on button click which will print the selected area or only html of div. pass the id of div on calling javascript function.
function CallPrint(var strid)
{
var prtContent = document.getElementById(strid);
var WinPrint = window.open('','','letf=10,top=10,width="450",height="250",toolbar=1,scrollbars=1,status=0');
WinPrint.document.write("<html><head><LINK rel=\"stylesheet\" type\"text/css\" href=\"css/print.css\" media=\"print\"><LINK rel=\"stylesheet\" type\"text/css\" href=\"css/print.css\" media=\"screen\"></head><body>");
WinPrint.document.write(prtContent.innerHTML);
WinPrint.document.write("</body></html>");
WinPrint.document.close();
WinPrint.focus();
WinPrint.print();
WinPrint.close();
return false;
}
Call CallPrint('DivGrid');" on onclick() of button or use below: but.Attributes.Add("OnClick", "return CallPrint('DivGrid');");
Nothing to do with .Net and everything to do with a print stylesheet. You can create a stylesheet which will only work for when the page is printed. And you can change everything from what displays to postion to colours.
Use:
<LINK rel="stylesheet" type"text/css" href="print.css" media="print">
Note media="print" means it'll be used for printed pages.
I know that question has been asked a long time ago, however there is no accepted suggestion. So here my approach for friendly print version when using Master page.
Create an empty master page (PrintVersion.Master) to serv as print version. Add what ever you need to be print (like logos) if anything to that master page.
from your content page, add a print link with target blank. Make the href to load the current page. From the href add a querystring so you can capture it from your content page preinit event.
From your content page preinit event detect if the querystring to print exists, then specify the blank master page like: MasterPageFile = "~/Ful/Path/of/your/PrintVersion.Master"
Optional, on the PrintVersion.Master on document.ready call: window.print(); The browser print dialog will automatically open.
You can make a new printable page version, which doesn't include a header. This version can also have the layout you need.
What is the best way to show the server-side generated HTML (full page) into a new popup window? It should be triggered upon clicking a button (causing a postback to the server).
Thanks
Edited:
The HTML content are dynamically generated in the code behind and the content is full page (<html> ... </html>). Upon clicking a button on the web page, I would like to get the generated html content and pass it to the browser and show it in a new popup window. The content will be the final result (UI) not HTML tags.
You can send the same page with mime type text/plain
For instance with a
<a href="same url?mime=textonly" target="_blank">
On the asp server, when the argument mime=textonly is detected, you change the mime type to text/plain
Perhaps I should have started with a comment to get more information but can you not:
Post back to a new window on click? <a target="_blank">
Though if the requirement is for the server to generate the new window, just append something like:
<script>window.open('title'); </script> at the end of the response and have the server populate that.
You could probably have the server code save the HTML to a file and output <script>window.open('urltothefile');</script>. Just make sure that you write a unique filename each time.
Alternatively, you could have the server code store all related information into a database and output <script>window.open('showResult.aspx?id=123');</script>, where 123 is the id of the database record. Then in showResult.aspx, have it generate the required HTML.
Another option is to output the HTML into a div with style="display: none", then have some javascript to assign the innerHTML to the newly opened window. eg:
var w = window.open ('_blank');
w.document.body.innerHTML = document.getElementById("returnedHTML").innerHTML
One more possibility is to have a WebMethod. I don't really remember how to declare one, but it is a server function that can be called from the client. Open the window via javascript, call the webmethod and place the result as the innerHTML of the newly opened window; Pretty much like the previous option.
All these are good but they don't work when you use UpdatePanel and partial rendering. If that's the case, it's a whole different story.
Using C#, ASP.Net
In my webpage i have the link for the another web page, if i click the link that should display a another page inside the main page like child page.
Another webpage should display like a popup window in my webpage. And also size of the another webpage should be small. How to do this.
Need Help.
For displaying one web page within another look at using frames (or an inline frame - iFrame)
The second part of your question I think is asking to be able to display the link in a separate window. To do this, use the target="blank" attribute in the anchor tag. to set the size of the child window you will need to use javascript:
<script type="text/javascript">
function showPopup(url) {
newwindow=window.open(url,'name','height=190,width=520,top=200,left=300,resizable');
if (window.focus) {newwindow.focus()}
}
</script>
So just call the showPopup method from your anchor click event
link text
Ideally you would move the javascript so that it is no longer inline, but this should work.
For the first part you need a master page
For the second part you might need a modal popup or it's jQuery equivalent
However, I don't understand what you mean with
And also size of the another webpage should be small. How to do this.
Another webpage should display like a
popup window in my webpage. And also
size of the another webpage should be
small. How to do this.
Did you mean a jQuery Modal Window?