how to show two web pages in one window without frames - c#

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.

Related

How to assign HTML content to iframe control from asp.net codebehind?

I want to assign the html content to iframe control from asp.net code behind page;
this is working fine
myIframe.Attributes.Add("src", "pathtofilewith.html");
but, i don't want to give the path of html file to display i just want to assign some html content which comes from database to iframe control.
i want some thing like this(Ashok) to be displayed in iframe control
i tried the bellow ways but nothing is succesful
myIframe.Attributes["innerHTML"] = "<h1>Thank You..</h1>";
myIframe.Attributes.Add("innerHTML", "<h1>Ashok</h1>");
A way to communicate between two different pages where one is in an IFrame on the other, is to post data using JQuery. An example is given in this StackOverflow question
It is also discussed in this other StackOverflow question
On this page, you will also find a short and simple example of how you can put content in an IFrame without using a separate web-page for it (note the lacking src attribute!).
Hope some of this helps!
You can't. That's not how an IFRAME works - it is for use with the src attribute as you've already discovered.
Perhaps you want to create a DIV instead
There is no way to insert HTML content into iframe tag directly, but you can create a page which gets the content form the database and then you can view it using iframe,
or
You can create a page for example called getContent.aspx which request value from the URL e.g. getContent.aspx?content=<h1>Thank You..</h1> and display it wherever you like, and then call it from iframe.

Child webpages help

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?

load a page with AJAX in a jQuery UI dialog without iframe

load a page with AJAX in a jQuery UI dialog without iframe
Actually you can get the output of an ASP.NET page via ajax and place it in jQuery UI dialog but I wouldn't consider it loading an ASP.NET page in the scrict sense as no postback/callback would ever work.
First, do your AJAX request to get the page, then put the contents in an element, then instantiate the dialog:
$.get('YourPage.aspx', function(html) {
$('div').html(html).dialog();
});

How can I set a variable in my pages javascript based on my controller action in ASP.NET MVC?

So, I have a page that looks like the following:
alt text http://img704.imageshack.us/img704/5973/croppercapture3.png
This is my basic messaging inbox. I have 2 pages right now, Inbox and Sent (there will eventually be others). These both share the same View, and just have 2 different actions to populate the appropriate data.
The elements on the right-hand side (the message list) is a partial view which has its data populated based on my two controller actions Inbox(int? page) and Sent(int? Page).
So, I have one view "MessageView" and one partial view "MessageList" shared between Inbox/Sent.
However, I now have to get those arrow buttons ("<" ">") working using Ajax. I know how to use jQueries ajax calls well enough, and I know how to render the result of the action call (which returns a partial view).
The problem comes from the fact that the javascript that makes these pagination ajax calls needs to know two things:
What the current page is (whether it be /messages/inbox or /messages/sent)
What the current page is (specified in the query string, ie /messages/inbox?page=2).
Without knowing which page I'm on (Inbox or Sent), it wont know which url to make the ajax call on. Should it make the postback to /messages/inbox or to /messages/sent?
If I wasn't making these messages load with Ajax it would be as simple as loading the appropriate url into the link tags for the "<" and the ">" buttons. But I can't, because part of my requirements states that it must load the messages below without visibly refreshing to a new page.
In JavaScript you can check window.location.pathname to see the pathname section of the current’s page’s URL.
window.location.search gives you the query string.
When the user clicks the Inbox or Sent buttons, you need to rewrite the URLs in your arrows so that they point to the right place.

Refresh only the content panel in master page on page navigation in asp.net mvc

I have a master page with Header, Menu, Content and Footer panes in my asp.net mvc (C#) application.
I don't want the Header and Footer panes to refresh on each page navigation, only the Menu and Content panes should get refreshed.
How can i achieve it in the asp.net mvc application? any suggestions
A pure ajax load of the inside of the pages could be achieved by capturing link clicks in the navigation to something like:
$('a:not(.external)').each(function(){
$(this).attr('href', '#'+this.href);
});
Then you could use the jQuery BBQ plugin to manage your back button and page loads with the 'onHashChange' event. This will allow you to ajax load each of the main portions of the page (likely with a $('#main-div').load(url); type call). The demo for BBQ does pretty much exactly what you'd like, with the added benefit that you don't ruin the back button, so I would suggest taking a hard look at that.
Make Ajax calls to the controller, like below and create the "*.ascx" PartialView you need
$('#divMainContent').load("./LoadMainContent");
[Authorize]
public ActionResult LoadMainContent()
{
return PartialView("MainContent", sp);
}

Categories

Resources