kwilliams Posted July 6, 2007 Share Posted July 6, 2007 My site uses a XML/XSL transformation using an ASP.NET page, and I'm trying to reset one of the XSL doc's parameters depending on a querystring value (ex: default.aspx?record_id=pw). But I'm getting an error, and I'm not sure how to solve it. This is what I have so far:ASP.NET DOC 'Assign XML and XSLT docsDim strThisPage_xml As String = "/docs/xml/default.xml" 'XML doc stringDim strThisPage_xsl As String = "/docs/xslt/default.xsl" 'XSLT doc string'Declare querystring variableDim recordId_qs As String = Request.QueryString("record_id")'Create the XsltArgumentList objectDim args As New XsltArgumentList()args.AddParam("record_id", "", recordId_qs)'Assign maincolumn XML/XSLT transformation propertiesxslTransform_mc.DocumentSource = strThisPage_xmlxslTransform_mc.TransformSource = strThisPage_xslxslTransform_mc.TransformArgumentList = args RESULT:ERROR:System.ArgumentNullException: Value cannot be null.Value cannot be null. Parameter name: parameterAnd if I add the following code above the "Assign maincolumn XML/XSLT transformation properties" set of code, it works:'Declare default querystring variablesIf recordId_qs = "" Then recordId_qs = "default"End IfBut I obviously know that this isn't the correct way to solve it. I read some stuff on how to dataset, but do I need to do the same for a string? Anyway, if you could point me in the right direction, that would be very helpful. Thanks. Link to comment Share on other sites More sharing options...
boen_robot Posted July 6, 2007 Share Posted July 6, 2007 How about testing if the value is empty and not pass any parameter if so? That way, the default value as specified in the XSLT stylesheet will be used.That is, instead of If recordId_qs = "" ThenrecordId_qs = "default"End If use something like (note that I don't know VB): If recordId_qs != "" Thenargs.AddParam("record_id", "", recordId_qs)End If Link to comment Share on other sites More sharing options...
kwilliams Posted July 6, 2007 Author Share Posted July 6, 2007 How about testing if the value is empty and not pass any parameter if so? That way, the default value as specified in the XSLT stylesheet will be used.That is, instead ofIf recordId_qs = "" ThenrecordId_qs = "default"End If use something like (note that I don't know VB): If recordId_qs != "" Thenargs.AddParam("record_id", "", recordId_qs)End If Thanks for the quick reply boen_robot.I added your suggested code like so:Dim args As New XsltArgumentList()If recordId_qs <> "" Then args.AddParam("record_id", "", recordId_qs)End If...and it worked great. I can't believe that I didn't figure that out on my own. I really appreciate your help. Have a good one. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.