Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

form variables in runat="server"

Status
Not open for further replies.

emms

Programmer
Jan 11, 2001
55
GB
I *really* am a newbie at this, so appologise if I'm asking the blindingly obvious.

how would I reference a form variable in a script I've set up to run at the server?

here's the code i've got:

<script language=&quot;VB&quot; runat=&quot;server&quot;>
Sub Page_Load(sender as Object, e as EventArgs)
Dim url as String = &quot; + Request.Form(&quot;xmlfile&quot;)
Dim ds as DataSet = new DataSet()
ds.ReadXml(url)
DL.DataSource = ds.Tables(0).DefaultView
DL.DataBind()
End Sub
</script>


which is throwing up an error... what do i need to use in place of Requst.Form?

thanks for any help

Emma
 
The request.form should work. . . why do you have a semi-colon in that line of code? If you take it out, it will probably work.

If not, what error is it giving?

Kevin B.
.Net Programmer [thumbsup]
 
thanks for your reply.

not sure why there was a semi-colon in the code I pasted here. There's not one in my code and it still doesn't work.

the error I get is:

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentException: Invalid byte was found at byte index 1342.

- not the most useful!


Emma

- can you tell me how to turn on the debug mode?
 
Hmmm. . . okay, too bad it wasn't the simple solution. . . . those are always more fun!

The error you are getting is a product of the ds.ReadXML(url) statement. The XML you are trying to read probably has some sort of weird character in it. Try using a XMLTextReader to read in the XML first. . . it may solve your problems. The new line would look like this:

ds.ReadXML(new system.XML.XMLTextReader(url))

This should decode all of the weird characters that may be found in your XML file.

HTH!





Kevin B.
.Net Programmer [thumbsup]
 
Hi Kevin,


thanks so much for your help with this... however...

I changed the code as you suggested so now it reads:

<script language=&quot;VB&quot; runat=&quot;server&quot;>
Sub Page_Load(sender as Object, e as EventArgs)
Dim url as String = &quot; + Request.Form(&quot;xmlfile&quot;)
Dim ds as DataSet = new DataSet()
ds.ReadXML(new system.XML.XMLTextReader(url))
DL.DataSource = ds.Tables(0).DefaultView
DL.DataBind()
End Sub
</script>

i still get the same error in the same place...

getting frustrated now!

Em
 
can anyone suggest anything for this? It's supposed to be working soon... think I'm a little out of my depth!

- oh and again that semi-colon is not in the code...

thanks

Emma
 
Emma,

Check out this post on .Net 247:


It seems that he had the same problem that you have and was able to fix it. It is basically the same fix as I gave you, but he uses a bit different way to get the XML (uses an IOStream)

Just thought I would pass it along. . . maybe it will give you a new direction to try!



Kevin B.
.Net Programmer [thumbsup]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top