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);
});
Related
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;
My site is written in C# with ASP.NET, all pages being loaded are .aspx pages.
I'm using a button
<input type="button" onclick="FindBuilding()">
to trigger a javascript function
function FindBuilding() {
$('#BuildingPopup).load('./BuildingPopup.aspx?lid=xxx');
$('#BuildingPopup).dialog('open');
}
that opens a modal dialog I've created
$("#BuildingPopup").dialog({
modal: false,
autoOpen: false,
position: "center",
resizable: false,
height: 671,
width: 1042,
stack: true
});
The dialog is created inside $(document).ready function
The Problem:
After the dialog loads BuildingPopup.aspx the parent page then loads the same page -- this happens anytime I try to load any page in a modal dialog, regardless of content. BuildingPopup.aspx is just an example.
What I have tried to fix it:
I have tried creating the dialog first, then loading the page using the open button. I have also tried using an iframe which works but the pages never display well and it's a hassle/bad fix.
Some clues?
Some of the pages are calling a web service through AJAX during page load
The problem persists on pages with and without updatepanels
Some pages are evaluating code blocks during page load
UPDATE
I have discovered that the problem occurs when an updatepanel on the parent page updates.
<asp:UpdatePanel ID="updatepanel1" runat="server" ChildrenAsTriggers="true" UpdateMode="Conditional">
This occurs when an <asp:Timer> executes an OnTick() method in the codebehind(to update the panel).
Hmmm I had the same problem as this, and I solved it by using update panels for any code that required a callback, not sure why that would not work...
Tuns out I just needed to phrase my question better -- I finally found someone else who was having the same problem as me.
Answer was found here: UpdatePanel within jQuery.load()-ed content breaks out of the page on postback
In a nutshell the problem was that using .load was pulling in extra tags from the loaded page that was breaking the HTML on the parent page. <head> <title> etc were being pulled into the parent page and causing the problems.
To fix the problem all that was needed was to specify what content I wanted to pull from the loaded page using .load(/loadedpage.aspx #content) instead of pulling the whole page.
So I'm trying to use C# to grab stored HTML in a database and then display it between a set HTML header and footer (I have a couple of these for different pages, so a masterpage would make life more complicated rather than less. I also come from a PHP background where this is sort of the way things work).
<!--#include virtual="header.html" -->
<% #Page Language="C#" Debug="true" %>
<% #Import Namespace="System.Data.Odbc" %>
<% #Import Namespace="System.Web.Configuration" %>
<script language="C#" runat="server">
void Page_Load(object sender,EventArgs e) {
//Gets the HTML Successfully
//Response.Write(fetched_html);
}
</script>
<!--#include virtual="footer.html" -->
Unfortunately with the current workflow the code generates content before the header or footer are put on the page, putting all the stored HTML at the top of the page before the header. I've tried a couple different Page_Events and none of them seem to work, so I need to know what to do.
Is there an equally simple way to reference and insert a simple html header file that would render before any of the Page_Events? I've tried Page_PreLoad and others to no success. Either the code is not fetched at all or I run into the same issue.
Use a MasterPage with a ContentPlaceholder. Then, on the content page, use a Literal and put the HTML in there.
See "The difference between literal and label".
Try this:
Assuming you have data holding some where in memory like datatable or dataset or collection.
To display a html text on the page we generally use <asp:Literal/>. So place a asp literal control on the page. It works in between <body> </body> tag.
Now render the text to the control using its Text property. e.g.
ltl.text = dt.rows[0]["htmlcol"].tostring();
To dynamically add text inside <head> </head>, u need HtmlMeta,Page etc class.
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>
I have an ascx control that is loaded in an aspx page.
How can I instruct my ascx to run javascript once it is rendered in the browser.
It should run on every postback as well.
I looked around but could not find a satisfactory answer.
Have you tried using the "RegisterStartupScript" method along with JQuery to call a JS function?
This code might help you:
ScriptManager.RegisterStartupScript(Page, GetType(Page), "myScript", "$(function() {{ alert ('Your page is loaded.'); }});", True)
You can replace the alert with any JS function you want :)
I hope this helps.