User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 373,377 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,701 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 2626 | Replies: 85 | Solved
Reply
Join Date: Oct 2007
Location: Bristol, UK
Posts: 1,122
Reputation: majestic0110 is on a distinguished road 
Rep Power: 3
Solved Threads: 46
majestic0110's Avatar
majestic0110 majestic0110 is offline Offline
Veteran Poster

Re: Last q on this project I promise lol

  #41  
Feb 6th, 2008
right I understand ok. But wont the thank you page restrict this project to only allowing one xml to be transformed per session ?
Reply With Quote  
Join Date: Oct 2007
Location: Bristol, UK
Posts: 1,122
Reputation: majestic0110 is on a distinguished road 
Rep Power: 3
Solved Threads: 46
majestic0110's Avatar
majestic0110 majestic0110 is offline Offline
Veteran Poster

Re: Last q on this project I promise lol

  #42  
Feb 6th, 2008
tried to response.redirect, gettting same exception when debugging. odd. man I owe you some beers!
Last edited by majestic0110 : Feb 6th, 2008 at 11:28 am.
Reply With Quote  
Join Date: Sep 2007
Posts: 1,054
Reputation: SheSaidImaPregy is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 61
SheSaidImaPregy SheSaidImaPregy is offline Offline
Veteran Poster

Re: Last q on this project I promise lol

  #43  
Feb 6th, 2008
http://aspalliance.com/259
http://www.dotnetspider.com/kb/Article1802.aspx

And no, it does not restrict anything. The thank you page could easily just say "file converted successfully. Your download should start in a few seconds. If you want to start the download manually, click here.

To convert a new file, please click here."

Something like that.
Reply With Quote  
Join Date: Oct 2007
Location: Bristol, UK
Posts: 1,122
Reputation: majestic0110 is on a distinguished road 
Rep Power: 3
Solved Threads: 46
majestic0110's Avatar
majestic0110 majestic0110 is offline Offline
Veteran Poster

Re: Last q on this project I promise lol

  #44  
Feb 6th, 2008
right ok...thanks for the links I have skimmed through them. So a good idea is to maybe let a user transform as many files as they want then maybe have a CLOSE button (or whatever) that brings them to a page where they download the transformed files?
Reply With Quote  
Join Date: Sep 2007
Posts: 1,054
Reputation: SheSaidImaPregy is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 61
SheSaidImaPregy SheSaidImaPregy is offline Offline
Veteran Poster

Re: Last q on this project I promise lol

  #45  
Feb 6th, 2008
or they can just repeat the process.
Reply With Quote  
Join Date: Oct 2007
Location: Bristol, UK
Posts: 1,122
Reputation: majestic0110 is on a distinguished road 
Rep Power: 3
Solved Threads: 46
majestic0110's Avatar
majestic0110 majestic0110 is offline Offline
Veteran Poster

Re: Last q on this project I promise lol

  #46  
Feb 6th, 2008
ok man thanks a million for all your help with this. Iill let you know how I get on with it. I think I will use a button on the same page that I shall call DOWNLOAD where a user can choose to download the files to where they want (like a dialog box).
Reply With Quote  
Join Date: Sep 2007
Posts: 1,054
Reputation: SheSaidImaPregy is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 61
SheSaidImaPregy SheSaidImaPregy is offline Offline
Veteran Poster

Re: Last q on this project I promise lol

  #47  
Feb 6th, 2008
Yup, no problem.
Reply With Quote  
Join Date: Oct 2007
Location: Bristol, UK
Posts: 1,122
Reputation: majestic0110 is on a distinguished road 
Rep Power: 3
Solved Threads: 46
majestic0110's Avatar
majestic0110 majestic0110 is offline Offline
Veteran Poster

Re: Last q on this project I promise lol

  #48  
Feb 6th, 2008
got hold of the correct XSLT now, but it doesnt seem to be Transforming the xml files at all. Now I know the XSLT is correct as I have checked it over several times. Is the code wrong somewhere?
Reply With Quote  
Join Date: Oct 2007
Location: Bristol, UK
Posts: 1,122
Reputation: majestic0110 is on a distinguished road 
Rep Power: 3
Solved Threads: 46
majestic0110's Avatar
majestic0110 majestic0110 is offline Offline
Veteran Poster

Re: Last q on this project I promise lol

  #49  
Feb 6th, 2008
hmm Ill give it a bash now and sign off will let you know how it goes. many thanks again for the help its great
If you have a quality, be proud of it and let it define you. Add it to the world!
If you got your answer, please mark the thread as Solved. It saves time when people are looking to contribute threads or for answers!
Reply With Quote  
Join Date: Oct 2007
Location: Bristol, UK
Posts: 1,122
Reputation: majestic0110 is on a distinguished road 
Rep Power: 3
Solved Threads: 46
majestic0110's Avatar
majestic0110 majestic0110 is offline Offline
Veteran Poster

Re: Last q on this project I promise lol

  #50  
Feb 7th, 2008
Right ok, I think I have a good idea as to what the problem is. I have saved the file before I have applied the XSLT (duh!lol) but also I am not sure the fileupload box is the best way to go about this. I think this because I cannot think of a way to transform the XML before it is saved? Any ideas ?


using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using System.Xml;
using System.Xml.Xsl;
using System.Xml.XPath;
using System.IO;


namespace runXslt { }

public partial class Default2 : System.Web.UI.Page
{

    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        // Specify the path on the server to
        // save the uploaded file to.
        String savePath = "C:/temp/";     

        // Get the name of the file to upload.
        String fileName = FileUpload1.FileName;

        // Get the extension of the uploaded file.
        string extension = System.IO.Path.GetExtension(fileName);

        // Before attempting to perform operations
        // on the file, verify that the FileUpload 
        // control contains a file.
        if (FileUpload1.HasFile)
        {
            if ((extension == ".xml"))
            {                     
                // Append the name of the file to upload to the path.
                savePath += fileName;
                               
                // Call the SaveAs method to save the 
                // uploaded file to the specified path.
                // If a file with the same name
                // already exists in the specified path,  
                // the uploaded file overwrites it.
                FileUpload1.SaveAs(savePath);
           
                // Notify the user of the name of the newly saved file
                Label1.Text = "SUCCESS! - Your file was uploaded and converted as " + fileName;
                

                //call XSLT transform
                ApplyXSLTransformation();
            }

            else
            {
                // Notify the user why their file was not uploaded.
                Label1.Text = "ERROR - Your file was not uploaded or converted because " + 
                    fileName + "it does not have a .xml extension.";

            }
        }

        else
        {
            // Notify the user that a file was not uploaded.
            Label1.Text = "ERROR - You did not specify a file to upload.";
        }
    }

    protected void LinkButton1_Click(object sender, EventArgs e)
    {

    }

    private string ApplyXSLTransformation()
    {
        string strHtml;

        string strXstFile = Server.MapPath("test.xslt");
        XslCompiledTransform x = new XslCompiledTransform();

        // Load the XML - use (Server.MapPath("/temp/" + FileUpload1.FileName));
        //if using server i.e. not local machine
        XPathDocument doc = new XPathDocument(("C:/temp/" + FileUpload1.FileName));

        // Load the style sheet.
        XslCompiledTransform xslt = new XslCompiledTransform();
        xslt.Load(strXstFile);
        MemoryStream ms = new MemoryStream();
        XmlTextWriter writer = new XmlTextWriter(ms, null);
        StreamReader rd = new StreamReader(ms);
        xslt.Transform(doc, writer);
        ms.Position = 0;
        strHtml = rd.ReadToEnd();
        rd.Close();
        ms.Close();
        Server.Transfer(Server.MapPath("C:/temp/dl" + FileUpload1.FileName));
        return strHtml;
       
    }
}
If you have a quality, be proud of it and let it define you. Add it to the world!
If you got your answer, please mark the thread as Solved. It saves time when people are looking to contribute threads or for answers!
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb ASP.NET Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the ASP.NET Forum

All times are GMT -4. The time now is 3:12 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC