Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / XML / February 2008

Tip: Looking for answers? Try searching our database.

reading a xml value from textbox on asp.net page

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
deepak - 08 Feb 2008 18:52 GMT
Hi All,

On a asp.net web page, i have a text box and a button ('Submit') , the text
box has below contents

<SXPTaskUpdateOrAdd Revision="7.5.0" Source="India_Bharti">
<Task>
<NOCRefID>SH123456</NOCRefID>
<TaskType>Corrective</TaskType>
<EarlyStart>2006-02-03T00:00:00</EarlyStart >
<DesiredDueDate>2006-02-05T00:00:00</DesiredDueDate >
<NumberOfRequiredEngineers>1</NumberOfRequiredEngineers>
<AutoCreate>true</AutoCreate>
</Task>
</SXPTaskUpdateOrAdd>

in my VB.NET code(ASP.NET), i want to read value of EarlyStart during
pageload event i.e. here it is 2006-02-03T00:00:00 inside <EarlyStart > tag.

How can i read it?Kindly Guide me please

Thanks,
Deepak
kr_deepak123@hotmail.com
kr_deepak123@yahoo.co.in
Joe Fawcett - 08 Feb 2008 19:18 GMT
> Hi All,
>
[quoted text clipped - 23 lines]
> kr_deepak123@hotmail.com
> kr_deepak123@yahoo.co.in

With a small document like this you can use XmlDocument from Sytem.Xml.
Load the XML:
 doc.LoadXml(myTextbox.text)
Read the EarlyStart data:
 XmlNode start = doc.SelectSingleNode("/*/EarlyStart")
Convert to a DateTime:
 DateTime dt = XmlConvert.ToDateTime(start.InnerText,
XmlDateTimeSerializationMode.Utc)
(May want to change the serialization mode enum depending on what you do
with the info.)

Signature

Joe Fawcett (MVP - XML)
http://joe.fawcett.name

deepak - 08 Feb 2008 19:24 GMT
Hi Joe,

Actually this asp.net page(having text box) is just a demo within us but  in
production environment with customers, they will send this xml message
through http protocol then how we shoudl read this...kindly tell me i would
be greatful to u...

> > Hi All,
> >
[quoted text clipped - 34 lines]
> (May want to change the serialization mode enum depending on what you do
> with the info.)
deepak - 08 Feb 2008 23:11 GMT
Hi Joe,
the question is that how to get this xml as there is no textbox in real
production environment and this xml message will come through internet via
http protocol.
tHIS PAGE dont play any role in actual production environment and this is
just asumption that we r goign to process the message of production (present
in this text box) through this page but in actual the same xmlmessage
willcome through http protocol... then how to get the xml message through
request object like request.form.getvalues(...).....Kinldy tell me i would be
highly helped by this?

> Hi Joe,
>
[quoted text clipped - 41 lines]
> > (May want to change the serialization mode enum depending on what you do
> > with the info.)
Martin Honnen - 09 Feb 2008 12:03 GMT
> Actually this asp.net page(having text box) is just a demo within us but  in
> production environment with customers, they will send this xml message
> through http protocol then how we shoudl read this...kindly tell me i would
> be greatful to u...

Assuming you have an ASP.NET page and that receives a HTTP POST request
with the XML in the request body then you can read in the XML as follows

  Dim doc As New XmlDocument()
  Try
    doc.Load(Request.InputStream)
    ' now use doc here e.g.
    Dim earlyStart As XmlNode =
doc.SelectSingleNode("SXPTaskUpdateOrAdd/Task/EarlyStart")
  Catch e As XmlException
    ' handle exception here
  End Try

Signature

    Martin Honnen --- MVP XML
    http://JavaScript.FAQTs.com/

deepak - 09 Feb 2008 17:48 GMT
Hi Martin,
Hope u r fine. I tried your code i.e. Request.InputStream but its giving me
'nothing' in quick watch of Visual Studio IDE then i tried
Request.Form.Item("SXP").GetValue(0) ,its also giving me nothing(and hence
error object refrce not set to instance of object)

but if i try to add any attachment file (say hi.txt) through 2nd texbox
present in the asp.net page(as i tokd u before ther are 2 textboxex available
on that asp.net page 1. for sending sxptaskuodate or add message
2. for adding any attachment with sxptaskupdateoradd mesage after browsing
the file say hi.txt.

so if i try to add any attachment and then lick on submit while sending the
sxptaskupdateoradd message , i gets that entire sxp message in  
Request.Form.Item("SXP").GetValue(0) as string i.e. "<SXPTaskUpdateORAdd...."

why it is so means the question is that if i add any attachment then i can
read this sxptaskupdateorAdd in Request.Form.Item("SXP").GetValue(0)  but if
i dont add any attachment file i.e. that texbox having path of file is empty
then i dont get anything in Request.Form.Item("SXP").GetValue(0) and gets
"object refercene not set to instance...." error .My aim is to read that
sxptaskupdateoradd message even if there is no attachment file with this
message.Your way Request.InputStream is giving me null value.

In actual producion environment this SXPTaskUpdateorAdd will come via http
protocol throgh internet and this asp.net demo page will not be there.This
page is with us just to do testing on our side as a demo assmuing that this
message is comign from customer side.

Kindly give some more efforts,it would be great help for me and my project
really.

- Deepak
kr_deepak123@hotmail.com
kr_deepak123@yahoo.co.in

> > Actually this asp.net page(having text box) is just a demo within us but  in
> > production environment with customers, they will send this xml message
[quoted text clipped - 13 lines]
>      ' handle exception here
>    End Try
Martin Honnen - 09 Feb 2008 18:05 GMT
> In actual producion environment this SXPTaskUpdateorAdd will come via http
> protocol throgh internet and this asp.net demo page will not be there.This
> page is with us just to do testing on our side as a demo assmuing that this
> message is comign from customer side.

Well my suggestion to use Request.InputStream is meant to be used when
you have an ASP.NET page to which someone makes a HTTP POST request with
the XML sent in the request body. So assuming you have
http://example.com/receive.aspx and someone makes a HTTP POST request to
that URL then you can use Request.InputStream and read out the posted XML.

Signature

    Martin Honnen --- MVP XML
    http://JavaScript.FAQTs.com/

deepak - 09 Feb 2008 18:42 GMT
hey martin,

may u give me urs any messenger id(hotmail or yahoo)?

> > In actual producion environment this SXPTaskUpdateorAdd will come via http
> > protocol throgh internet and this asp.net demo page will not be there.This
[quoted text clipped - 6 lines]
> http://example.com/receive.aspx and someone makes a HTTP POST request to
> that URL then you can use Request.InputStream and read out the posted XML.
deepak - 11 Feb 2008 13:15 GMT
Hi Martin,

your method of using Request.InputStream is working fine.i juct debugged
and checked and its showing values in quick watch...thanks a lot
again....really..

Thanks,
Deepak

> hey martin,
>
[quoted text clipped - 10 lines]
> > http://example.com/receive.aspx and someone makes a HTTP POST request to
> > that URL then you can use Request.InputStream and read out the posted XML.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.