Open an ASP control inside Jquery modal dialogue - c#

I have a requirement to open up a Jquery modal dialogue but it's contents needs to be either a .aspx or .ascx, is this possible?
I know that the dialogues usually open a div from the same page but I need to be able to load them up from other places and need to be able to send data to and from the modal contents as well.
Any help is appreciated.

The easy way is to place the control on another page and then load it into the dialog with iframe. (how?)

You can use jQuery.load
$("#mydiv").load("pageToLoad.aspx #container");
pageToLoad.aspx:
<html>
<body>
<div id="container">
<!--stuff goes here -->
</div>
</body>
</html>
Probably it will work but haven't tried it.

You could do this using iframe.
http://www.w3schools.com/tags/tag_iframe.asp
1) create separate .aspx page with content you want to show in dialog;
2) in the page add div with iframe inside it;

Related

How do I use my HTML page inside my ASP.NET page?

I have a .html.
I also have a .aspx that have two panels. I want to display my .html page between the panels, how can I do that?
I would like my .aspx page to end up with following structure. If I just drag the .html file in, it only creates a hyperlink. Should I put the .html code into a asp web forms instead?
...
<asp.Panel ...>
</asp.Panel>
.html
<asp.Panel ...>
</asp.Panel>
...
If you want it in the same page, you could just paste the contents of the html body between your panels.
If your html is going to change in future, and you want it to remain a different page, use an iframe and set it to display your html page.
If you want to combine both on the fly, you can use a asp.net Literal control, read the contents of your html page and set the contents of the html to the Text property of Literal
You can use iframe to display html page.
Use like this:
<iframe width="100%" height="100%" src="a.html" />
Convert your html page as user controls. Then include that user controls in aspx page.
Details:
1. Create a user control. ( .ascs extention file ).
2. Place html code inside user control.
3. Create asp page.
4. Include user control in asp page via following code.
<%# Register src="control.ascx" tagname="controlName" tagprefix="pre" %>
<pre:controlName ID="controlId" runat="server" />

Displaying a content page as popup in asp.net,using

I have a content page(Say.. invoice.aspx) in asp.net application with master pages.
The content page(invoice.aspx) is using a gridview, which displays records from database.
Currently i am navigating to this page using - Response.redirect("invoice.aspx") and this is working fine.
But i need to display this page as pop-up from calling page, so that this popup invoice can be seen on the top of other pages.
Please help me if this can be done using javascript or some other way.
Thanks in advance..
A page popup can be implemented using a div as a container with a different style (opacity, window position, size etc) and has a higher z-index than the rest of the page.
thus basically you need a structure like
<div class="overlayOuter">
<div class="overlayInner">
<!-- external content to be loaded here -->
</div>
</div>
and now using AJAX you load the invoice.aspx page to the inner container and show the container and reduce the opacity of the outer container.
There should be libraries out there that let you do this. you need to explore that on your own.
You can use modal popups for the above scenario:
one example can be found here: http://sandbox.scriptiny.com/tinybox2/
its easy and not much code you need to write and also can load popup as an iframe so postbacks can be handled without posting back parent page or you can use ajax
function OpenWindow(strChildPageUrl) {
var testwindow = window.open(strChildPageUrl, "Child", "width=700px,height=650px,top=0,left=0,scrollbars=1");
testwindow.moveTo(100, 0);
}
</script>

how do I show a string as html content in web form

I am trying to retrieve a html document to show in my web page, now the content comes from database as a string. Now I know there is a way to do this in win forms using Browser.DocumentText. But how do I do this in web form?
I tried the setting the innerHTML property for a div inside of the "OnRowCommand", the "OnRowCommand" happens to be inside an update panel. When I move the Div outside the panel, say to just below the body, it renders well.
Well there are many ways to do this, you can use a label, literal Controls.
Or maybe defining a public string within your page then use it directly in your html as:
<%= strSomeString %>
Add a literal control in aspx file and in codebehind set
Literal1.Text=data_from_DB;
Try this one:
html code:
<div id="webcontent" runat="server">
</div>
Code behind:
webcontent.InnerHtml = FromDBstring;
Write up for Mvc app Html.Raw('html tages') or MvcHtmlString.Create('html tages') and for web form HttpUtility.HtmlEncode('html tages')

Refresh page button using C#

I want to create a button in visual studio that refreshes the entire browser page. Currently, I have a web part that is deployed onto sharepoint 2010. I would like to add a button to refreshes the page dynamically so that my web part content changes. It is because, my web part has a random code which changes information every 10 seconds, but to view the changes the page has to be refreshed constantly. I want to just add a button to my web part to hit refresh. Is it possible?
There's a few ways, but all use JavaScript on the button. Here's my favourite:
<input type=button value="Refresh" onClick="history.go()">
The "type=button" prevents the button from causing a postback. onclick="history.go() says to go to the last item in the history list, i.e. the current page.
use this one
input type="button" value="Reload Page" onClick="window.location.reload()
you can try this..... If you want to refresh the page in button click , you can set this into button click....
<html>
<head>
<script type="text/JavaScript">
<!--
function timedRefresh(timeoutPeriod) {
setTimeout("location.reload(true);",timeoutPeriod);
}
// -->
</script>
</head>
<body onload="JavaScript:timedRefresh(5000);">
<p>This page will refresh every 5 seconds. This is because we're using the 'onload' event to call our function. We are passing in the value '5000', which equals 5 seconds.</p>
<p>But hey, try not to annoy your users too much with unnecessary page refreshes every few seconds!</p>
</body>
</html>

Problem with displaying my Image

Here is my full problem so if anyone has any ideas or can offer some help, please let me know. I have a Website that will generate a Report and this Report takes some time to create. There is a MyReport.ASPX file that has a form1, Image1, and a ReportViewer control. There is also a MyReport.cs file that has C# code to generated a HTMLText string that the ReportViewer control will display. When I pull the Website up in the browser, the MyReport.cs file creates the Report before MyReport.ASPX ever gets called so my Image1 (which I need to display while the Report is being created) never gets displayed until AFTER the Report is created and displayed.
What do you suggest I do here? If I did not supply enough information, please let me know what else you need to know and I will gladly post it.
Thanks,
The below is in response to Derek.
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
$(".loading").load("http://servername/Geocortex/Essentials/Web/SelectionReport1.aspx");
});
</script>
<%# Page Language="C#" AutoEventWireup="true" Codebehind="App_Code/MyReport.cs" Inherhits="Geocortex.Essentials.WebFramework.SelectionReportPage" Culture="auto" UICulture="auto" %>
One method would be to move the report generating code to a webservice, or PageMethod within your page. Have your aspx page display an image, then once the page is loaded, make an ajax call to your webservice (or Page Method), using js or jquery, and update the page (remove the image and display the report returned from the webservice).
<div id="loading">
<img src="..."/>
</div>
Then using jquery in the document.ready event:
$(document).ready(function(){
$(".loading").load(url of page with reportviewer control);
});

Categories