Click here to Skip to main content
15,914,201 members
Home / Discussions / Web Development
   

Web Development

 
AnswerRe: How to provide a toolboxbitmap to a Web Server Control? Pin
Andy Smith3-Apr-02 10:12
Andy Smith3-Apr-02 10:12 
GeneralThanx a lot, but I think you made sth ambiguous Pin
4-Apr-02 11:46
suss4-Apr-02 11:46 
GeneralRe: Thanx a lot, but I think you made sth ambiguous Pin
Andy Smith4-Apr-02 11:50
Andy Smith4-Apr-02 11:50 
GeneralRe: Thanx a lot, but I think you made sth ambiguous Pin
James T. Johnson4-Apr-02 12:01
James T. Johnson4-Apr-02 12:01 
Generalwebsphere and ASP Pin
Pradhip2-Apr-02 7:15
Pradhip2-Apr-02 7:15 
GeneralRefresh custom server control Pin
Ignacio Varas2-Apr-02 2:09
Ignacio Varas2-Apr-02 2:09 
Questionweb service??? Pin
Leesen2-Apr-02 0:54
Leesen2-Apr-02 0:54 
General<asp:xml> snag - this is killing me! Pin
1-Apr-02 10:30
suss1-Apr-02 10:30 
Literally, I'm losing it here!

Simply want to transform an xml document with an xsl stylesheet using the <asp:xml> control. The documents will be dynamic based on a provided parameter (querystring, form value, whatever) so I'm using the DocumentSource and TranformSource properties in my code-behind file to dynamically assign the xml and xsl documents.

I repeatedly get this error:

"Object reference not set to an instance of an object."

Now, I don't get the error if I use the DocumentSource and TransformSource attributes in the xml web control like this:

<asp:xml id="detailsXml" documentsource="file.xml" transformsource="file.xslt" runat="server"/>

Here is some code:

using System;
using System.Collections;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Xml;
using System.Xml.Xsl;

public class PFDetailsPage : System.Web.UI.Page
{
//xml web control
protected Xml detailsXml;

private void Page_Load(object sender, System.EventArgs e)
{
//xml and xsl files
string xmlFile = Server.MapPath("xdetails/details.xml");
string xslFile = Server.MapPath("xdetails/details.xslt");

//call transform method below
TransXmlFile(xmlFile, xslFile);
}

public void TransXmlFile(string xmlFile, string xslFile)
{
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(xmlFile);
detailsXml.Document = xmlDoc;

XslTransform xslDoc = new XslTransform();
xslDoc.Load(xslFile);
detailsXml.Transform = xslDoc;
}
}

I also tried just doing this but got the same exact error on the same lines of code:

private void Page_Load(object sender, System.EventArgs e)
{
string xmlFile = Server.MapPath("details.xml");
string xslFile = Server.MapPath("details.xslt");
detailsXml.DocumentSource = xmlFile;
detailsXml.TransformSource = xslFile;
}

I'm absolutely sure the files are there, as I said, I had no problem using static values in the web control itself, it's only when I try to provide it values manually in my code-behind class that I start getting errors.

Thanks ahead of time!!

-vConfused | :confused:
GeneralRe: <asp:xml> snag - this is killing me! Pin
MS le Roux1-Apr-02 19:48
MS le Roux1-Apr-02 19:48 
GeneralRe: <asp:xml> snag - this is killing me! Pin
Gerald Schwab1-Apr-02 19:55
Gerald Schwab1-Apr-02 19:55 
QuestionASP.Net custom control assembly (DLL) location? Pin
Stan Shannon1-Apr-02 4:50
Stan Shannon1-Apr-02 4:50 
AnswerRe: ASP.Net custom control assembly (DLL) location? Pin
James T. Johnson2-Apr-02 1:26
James T. Johnson2-Apr-02 1:26 
AnswerRe: ASP.Net custom control assembly (DLL) location? Pin
Todd Smith14-May-02 14:14
Todd Smith14-May-02 14:14 
AnswerRe: ASP.Net custom control assembly (DLL) location? Pin
Todd Smith14-May-02 15:32
Todd Smith14-May-02 15:32 
GeneralRe: ASP.Net custom control assembly (DLL) location? Pin
Stan Shannon14-May-02 16:48
Stan Shannon14-May-02 16:48 
GeneralCGI question... Pin
Philip Patrick31-Mar-02 2:10
professionalPhilip Patrick31-Mar-02 2:10 
GeneralRe: CGI question... Pin
31-Mar-02 10:54
suss31-Mar-02 10:54 
GeneralRe: CGI question... Pin
Philip Patrick31-Mar-02 11:13
professionalPhilip Patrick31-Mar-02 11:13 
GeneralRe: CGI question... Pin
alex.barylski31-Mar-02 23:30
alex.barylski31-Mar-02 23:30 
GeneralRe: CGI question... Pin
Nick Parker1-Apr-02 2:57
protectorNick Parker1-Apr-02 2:57 
GeneralUsing the Calendar ActiveX control in an HTMl form Pin
Nish Nishant30-Mar-02 22:48
sitebuilderNish Nishant30-Mar-02 22:48 
GeneralRe: Using the Calendar ActiveX control in an HTMl form Pin
Wanderley M1-Apr-02 10:31
Wanderley M1-Apr-02 10:31 
GeneralBringing pics from database Pin
Pradhip30-Mar-02 17:13
Pradhip30-Mar-02 17:13 
GeneralRe: Bringing pics from database Pin
Philip Patrick30-Mar-02 22:32
professionalPhilip Patrick30-Mar-02 22:32 
GeneralScript Encoder Pin
Philip Patrick30-Mar-02 13:24
professionalPhilip Patrick30-Mar-02 13:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.