Solved

How to make gif image invisible ??

Posted on 2008-10-05
6
1,012 Views
Last Modified: 2008-10-24
Hi,

     i have a grid which contains link for showing report in form of pdf.

     This we are doing through Sql server 2005 reporting services.

     Now when the link is clicked, a gif image is displayed showing the progress.

    The report is shown on a new page.

    What i want is when the new page is displayed the gif image should get hidden.

    I want when the report is finished loading then image should get inivisible.

Now how can i access gif from parent page from child page ???

On page load of child page i tried injecting javascript alert();

But the page is appearing in pdf format since i am using Sql server 2005 reporting services and

directly injecting data by saying Response.BinaryWrite();

So how can i fire javascript in such page ??????
0
Comment
Question by:Paramhans
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 22

Assisted Solution

by:Ivo Stoykov
Ivo Stoykov earned 250 total points
ID: 22647320
Hi Paramhans
you need a simple JavaScript attached to the onload event of the element showing report.
Because you didn't attache any source I've made a simple HTML sample snippet hoping you've catch the idea.
HTH
I

 <SCRIPT LANGUAGE="JavaScript">
 <!--
   function hideGif()
   {
     document.getElementById("test").style.display = "none";
   }
 //-->
 </SCRIPT>
 
<!-- your gif imege -->
<IMG SRC="1.jpg" WIDTH="320" HEIGHT="450" BORDER="0" ALT="" id="test">
<!-- your gif imege -->
<div id="report">report is loading in this div</div>

Open in new window

0
 

Author Comment

by:Paramhans
ID: 22656697
Hi Thanx 4 the reply.
I tried injecting javascript at runtime but it did not work.

Also i would like to explain the problem once again.

I have a link on Page1 on the click of which the Gif is displayed on same page and a new page called as Page2 which is responsible for showing report is displayed.

When page2 is completely loaded i want to hide Gif image on Page1 ?????
Since Page2 shows report using Sql server 2005 reporting services.

Injecting javascript is not working on Page2.

0
 

Author Comment

by:Paramhans
ID: 22656741

I have code in ItemCommand of Grid linkbutton on page1 as following:
           Context.Items.Add("SurveyID",Convert.ToString(e.CommandArgument));		
           Server.Transfer("~/User/PDFReport.aspx");
 
On Page2 (PDFReport.aspx) page_load event i have code to generate pdf report using reporting services as following:
                               Response.Clear();
				Response.Buffer= true;
				string fileName= System.Configuration.ConfigurationSettings.AppSettings["ReportName"];
				Response.ContentType = "application/pdf";
				Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName + "");
		
				SurveyReport1.ReportingService objRService =  new SurveyReport1.ReportingService();
				objRService.Url = System.Configuration.ConfigurationSettings.AppSettings["ReportingServiceURL"];
				objRService.PreAuthenticate = false;
				objRService.Credentials = System.Net.CredentialCache.DefaultCredentials;
				objRService.Timeout = 1000 * Convert.ToInt32(ConfigurationSettings.AppSettings["WebServiceTimeout"]); 
				string PDFData = objRService.GeneratePdfReport(Convert.ToString(Request.QueryString["SurveyID"]));
				
				byte [] bytData = Convert.FromBase64String(PDFData);
 
				Response.BinaryWrite(bytData);
 
This is the code for GeneratePdfReport() written in a class file:
 
		public string GeneratePdfReport(string surveyId)
		{
			try
			{
				SQLReportingService.ReportingService rs = new SQLReportingService.ReportingService();
				rs.Url = ConfigurationSettings.AppSettings["ReportingServiceURL"];
			
				rs.Credentials = CredentialCache.DefaultCredentials;
				byte[] result = null;
				string reportPath = ConfigurationSettings.AppSettings["ReportPath"];
				string format = "PDF";
				string historyID = null;
				string devInfo = @"<DeviceInfo><Toolbar>False</Toolbar></DeviceInfo>";
 
				// Prepare report parameter.
				ParameterValue[] parameters = new ParameterValue[1];
				parameters[0] = new ParameterValue();
				parameters[0].Name = "surveyId";
				parameters[0].Value = surveyId;
				
			
				string showHideToggle = null;
				string encoding;
				string mimeType;
				Warning[] warnings = null;
				ParameterValue[] reportHistoryParameters = null;
				string[] streamIDs = null;
				SessionHeader sh = new SessionHeader();
				rs.SessionHeaderValue = sh;
				try
				{
					result = rs.Render(reportPath, format, historyID, devInfo, parameters, null,
						showHideToggle, out encoding, out mimeType, out reportHistoryParameters, out warnings,
						out streamIDs);
					sh.SessionId = rs.SessionHeaderValue.SessionId;
					return Convert.ToBase64String(result);
				}
				catch (Exception)
				{
					return null;
				}
			}
			catch (Exception)
			{
				return null;
			}
 
		}

Open in new window

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 22

Assisted Solution

by:Ivo Stoykov
Ivo Stoykov earned 250 total points
ID: 22657589
Hi Paramhans
How correspond Page1 & Page 2? You must have onClick event in Page1, right?
I
0
 

Author Comment

by:Paramhans
ID: 22666230
On page 1 we have a link
When i click on that link lnkShow_click gets fired.
0
 
LVL 22

Accepted Solution

by:
Ivo Stoykov earned 250 total points
ID: 22667028
Well here is a possible solution

// default page (1 - report is called from)
<body>
    <form id="form1" runat="server">
    <div>
      <img id="myGif" src="#" /> <!-- your gif - must have an ID which is used in page2 -->
    </div>
    </form>
</body>
 
// page2 - report
    protected void Page_Load( object sender, EventArgs e )
    {
      String scriptString = "<script language=\"JavaScript\">\n";
      scriptString += "test();\n";
      scriptString += "function test() {  window.opener.document.getElementById('myGif').style.display='none';  } \n";
      scriptString += "<";
      scriptString += "/";
      scriptString += "script>";
 
      ClientScript.RegisterStartupScript(this.GetType(), "test", scriptString);
    }

Open in new window

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question