473,804 Members | 2,747 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Display .htm files content in .aspx page control

30 New Member
Dear sir,

I have a word document file contains text and images, now i have saved it as a web page and wants to display it on browser ,
using ,
string str=directory.g etfiles("");
response.conten tType="text/html";
response .writefile("");
it displayed in different format and images not shown
blank spaces shown as ?????????? and image as X.

i have no. of files stored as word file ,tried to display directly in gridview but it's not posible for me, so i converted them as web page and now i want to display 5 files dynamically in gridview including images., so help me out, looking for ur reply..

, can u tell me how it works, i will be thanxfull to u

i do not want to use web browser or process.start(" IExploreAsassr. exe","path") method because it displays only one file at a time , actually i want to dislay it in gridview item template, including pics.
Aug 20 '09 #1
23 19143
NitinSawant
270 Contributor
well, you can use <iframe> tag

Expand|Select|Wrap|Line Numbers
  1. <iframe src ="myFilePath.html" width="100%" height="300">
  2.   <p>iframes not supported</p>
  3. </iframe>
Aug 20 '09 #2
NitinSawant
270 Contributor
in response.write( "") pass parameter for showing the iframe tag with the desired file...

cheers,
Nitin
Aug 20 '09 #3
ssnaik84
149 New Member
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3.     <meta http-equiv="Content-Type" content="application/doc">
  4. </head>
  5. <body>
  6.     <iframe src="your-word-document-file.doc" width="100%" height="100%"> </iframe>
  7. </body>
  8. </html>
try this.
Aug 21 '09 #4
Frinavale
9,735 Recognized Expert Moderator Expert
Hi Shashi,

Have you tired viewing the HTML webpages generated by Word by themselves first?

Make sure that they display correctly before trying to use them in your asp application.

If they are working, consider using IFrames to display the webpages in the grid.
Aug 24 '09 #5
shashi shekhar singh
30 New Member
i am really respectfull to u all for ur reply, i want to use like this shown as below,
Expand|Select|Wrap|Line Numbers
  1.  
  2. <div>
  3.         <iframe id="iframe1" runat="server" scrolling="auto"  width="100%" height="100%"> </iframe>
  4.  
  5.     </div>  
Expand|Select|Wrap|Line Numbers
  1.   string[] getfile = Directory.GetFiles(@"D:\Shekhar Documents", "*.htm");
  2.             for (int i = 1; i < getfile.Length; i++)
  3.            {
  4.                HtmlControl frame = (HtmlControl)this.FindControl("iframe1");
  5.                //string path = Server.MapPath("1.htm");
  6.                frame.Attributes["src"] = getfile[i];
  7.            }
i am using this but it not displayed my file content, it only displayed http url.. like "http://www.google.com" , please help me out.. i am waiting for ur reply.
Aug 25 '09 #6
NitinSawant
270 Contributor
try displaying only single file on the page @shashi shekhar singh
Aug 25 '09 #7
shashi shekhar singh
30 New Member
Like
frame.Attribute s["src"] = getfile[i];
I am giving
frame.Attribute s["src"] = "D://shekhardocument s/1.htm";
then it's not displaying , am new for iframe so plzgive me reply.
Aug 26 '09 #8
NitinSawant
270 Contributor
@shashi shekhar singh
The src attribute should be internet url e.g. http://localhost/shekhardocuments/1.htm

and also you should add the html files in the project directory..
Aug 26 '09 #9
Frinavale
9,735 Recognized Expert Moderator Expert
@shashi shekhar singh
Ok, that wont work, your 1.htm file has to be located on the web server. That way web browsers can down load it using the URL specified as the src attribute.

You can't use a local file path to the 1.htm file...you have to use something like "http://localhost/mywebsite/statichtm/1.htm".

So, place all of the htm files into a folder located within your project. Then loop through the directory and create the URL based on the files you find there.

So you would have something like this to create the URLs:

Expand|Select|Wrap|Line Numbers
  1. string[] getfile = Directory.GetFiles(Server.MapPath("~/statichtm/"), "*.htm");
  2. List<string> staticHtmUrls= new List<string>();
  3.  
  4. for (int i = 1; i < getfile.Length; i++)
  5. {     string staticURL = "/statichtm/"+getfile[i];
  6.       staticHtmUrls.Add(staticURL );       
  7. }
So now you have a list of URLs to your static htm files.

I'm thinking that it will probably be easier for you to use a Repeater instead of a GridView.

So your ASP code would look like:

Expand|Select|Wrap|Line Numbers
  1. <asp:Repeater ID="staticWebPagesRepeater" runat="server">
  2.         <HeaderTemplate>
  3.              <table border="1">
  4.                 <tr>
  5.                    <td><b>Web Pages</b></td>
  6.                 </tr>
  7.           </HeaderTemplate>
  8.           <ItemTemplate>
  9.              <tr>
  10.                 <td> <iframe src="<%# Container.DataItem %>"></iframe></td>
  11.              </tr>
  12.           </ItemTemplate>
  13.           <FooterTemplate>
  14.              </table>
  15.           </FooterTemplate>
  16. </asp:Repeater>
And your C# code would have something like this:
Expand|Select|Wrap|Line Numbers
  1. private List<string> _repSource;
  2. protected void Page_Load(Object sender, System.EventArgs e) 
  3. {
  4.         _repSource =  new List<string>();
  5.         string fileNames[] = Directory.GetFiles(Server.MapPath("~/StaticHTM/"), "*.htm");
  6.         foreach (string name in fileNames)
  7.         {
  8.             string sp[] = name.Split('\');
  9.             string urlToStaticHTML = sp(sp.Length - 1);
  10.             _repSource.Add("/StaticHTM/" + urlToStaticHTML );
  11.         }
  12.         staticWebPagesRepeater.DataSource = _repSource.ToArray();
  13.         staticWebPagesRepeater.DataBind();
  14. }
  15.  
Aug 26 '09 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

6
2437
by: dale zhang | last post by:
Hi, I build a web form with a 4-cell table on the top (flawlayout), followed by some labels and textboxes (gridlayout). The web form is displayed well in dell m60 laptop with all resolution options and DPI options. However when I tried to run it in a dell P3 desktop, labels and textboxes overlapped each other and they were in table area too. Any suggestions? Do I have to put all controls in table cells?
11
3491
by: Tina | last post by:
I'm in a button clicked event on mainpage.aspx. I want to display a new webpage that has just my image, which is a jpg. I want the page to be a ..jpg not an aspx so that it will be easy for the user to save to disk. How can I do this? Thanks, T
4
2522
by: Rob Meade | last post by:
Hi all, I have just put together our organisations 'template' for our web applications and have created 7 .ascx files which when dropped into my template file work perfectly...however, I have a question... As our team develops several applications I wanted these generic .ascx's to be able to be used by all - therefore I've placed them in the root of the domain we work on in a directory called /WebUserControls
5
15822
by: David Elliott | last post by:
I need a control on a Web Page that can accept an HTML Document and will display it. Any help would be appreciated. Thanks, Dave Here is what I was trying...
7
5498
by: Oleg | last post by:
I have a web form let's say 'YYZ.aspx'. It has an iframe in it. When it loads it shows progress bar in IE this way: loading for page then again loading for page in iframe. This part is fine. Problem is when I put page 'YYZ.aspx' in iframe of another page, let's say 'Home.aspx'. In short: (page (page in iframe(page in iframe) ) ) Progress bar shows ones (fast), then second time(kind of fast) and then third time. And this time it never...
20
2431
by: Alan Silver | last post by:
Hello, In classic ASP, I used to use two include files on each page, one before and one after the main content, to provide a consistent layout across a web site. That way I could just change the include files to change the layout. When I came to ASP.NET, I used user controls to do a similar thing. I have just been looking at master pages, and it looks like they do the same thing. If so, is there any advantage in using them over the...
5
5052
by: Peter Lapic | last post by:
I have to create a image web service that when it receives an imageid parameter it will return a gif image from a file that has been stored on the server. The client will be an asp.net web page that calls the web service to render a vertical strip of images. After doing some research I am unable to find some vb.net code that can assist in what I want to achieve. The closest thing I found was
3
2253
by: c676228 | last post by:
Hi everyone, I have a piece of code in sales.aspx.vb like this: Protected WithEvents Message As System.Web.UI.WebControls.Label Try ... ChartImage.ImageUrl = "ChartGenerator.aspx?" + DataStr + "&ChartType=" + drpChartType.SelectedItem.Value.ToLower() + "&Print=" + printVersion.ToString() ... Catch e As Exception
9
2078
by: tomhawkins1 | last post by:
Hi I currently have a site where users can upload files. These files can be doc, wmv, jpeg, xls, dwf, dwf and dwg. These files are uploaded to /home/**user**/uploads and not /home/ **user**/public_html/uploads to prevent any old user from browsing them. I then use a general showDoc page with the following function (from
0
9711
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10594
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10331
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9166
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5529
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5667
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4306
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3831
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.