HOW TO READ DATA FROM HTML HIDDEN FIELD

Hi Experts,
I wrote an html file through CHtmlView support from appwizard application in vc++6. I have added
 a hidden field to the html document. I wrote some data using IHTMLInputHiddenElement interfaces
putvalue() method it takes BSTR data type as an argument.In my html document i gave path to
 iis4.0 asp server in my post(action ) method in my form.
      I am unable to write the data from the hidden field in to a file through my asp program.
Actually i am successfull in writing normal data to a file but problem arises when the data's
value is exceeding  256.
     I can retrieve data from the html document through my vc++ program and write it successfully
but i am failing to do through asp.
PSRISAIHARIAsked:
Who is Participating?
 
ShaunWildeConnect With a Mentor Commented:
ah I think you are opening your file in ascii mode - change OpenTextFile to be


set myWriteFile=Object.OpenTextFile("filepath",8,true,-1)

this should open it in unicode


0
 
DanRollinsCommented:
Show the code that is failing and decsribe any error messages and so forth that you see when it fails.

-- Dan
0
 
ShaunWildeCommented:
if you want to read what is in an hidden field from asp you can use the Request object and the QueryString method.

Also is the hidden field wrapped by the form you are submitting - I can't remember if that is important
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
PSRISAIHARIAuthor Commented:
Hi ShaunWalde and DanRollins
I wrote an html file through CHtmlView support from appwizard application in vc++6. I have added
 a hidden field to the html document. I wrote some data using IHTMLInputHiddenElement interfaces
putvalue() method it takes BSTR data type as an argument.In my html document i gave path to
 iis4.0 asp server in my post(action ) method in my form.
      I am unable to write the data from the hidden field in to a file through my asp program.
Actually i am successfull in writing normal data to a file but problem arises when the data's
value is exceeding  256.
     I can retrieve data from the html document through my vc++ program and write it successfully
but i am failing to do through asp.
      In Asp the code is like this
 data = request.form("hiddenStringName")
Set Object=Server.CreateObject ("Scripting.fileSystemObject")
set myWriteFile=Object.OpenTextFile("filepath",8,true)
myWriteFile.WriteLine(data)
   But what the data is being written into the file is different when compared to data which i wrote through my
vc++ program using WriteFile.
   The difference is in the data where the value is greater
than 256

 


   
 
0
 
DanRollinsCommented:
The phrase "greater than 256" is ambiguous.  Please show an example of data that works and an example of data that does not work.  Also describe in what way it does not work (do you get nothing, do you get just a little piece of data, do you get the wrong data, etc). and post here the data that the VC++ program sent and the data that the asp recieved.

Please, do not repeat the original question.  Thanks!

-- Dan
0
 
ShaunWildeCommented:
> greater than 256

do you mean string length ?

is it being limited by a MAXLENGTH attribute? - just guessing -

0
 
PSRISAIHARIAuthor Commented:
I get data values whose ascii values is less than 256.
For example

 unsigned short *no_ToSend;
 LPDISPATCH myDispatch;
 IHTMLDocument2 *myHtmlDocument;
 IHTMLElementCollection *myHtmlCollection ;
 IHTMLInputHiddenElement *myHtmlInputHiddenElement;    
 VARIANT myVariant,initVariant ;
 DWORD error=0;    
 no_ToSend=new unsigned short[8];


 for(i=0;i<8;i++)
   no_ToSend[i]=i+251;

      myDispatch=this->GetHtmlDocument();  //get html    document's idispatch
     if(myDispatch == NULL)
     {
          MessageBox("could not get html document");
          return;
     }          
     if((myDispatch->QueryInterface (IID_IHTMLDocument2,(void**)&myHtmlDocument))!=S_OK)//get html document interface
     {
          MessageBox("error in query interface");
          return;
     }
     if((myHtmlDocument->get_all (&myHtmlCollection))!=S_OK) // call getall method of html doc interface
     {
      MessageBox("error in get_all of myHtmlCollection");
     
 
 myVariant.vt = VT_UINT;
          myVariant.lVal = 5 + j ;
          VariantInit(&initVariant);//initializevariant before calling item method of collection

          if((myHtmlCollection->item (myVariant,initVariant,&myDispatch))!=S_OK)
          {
               MessageBox("error in htmlcollection's item method");
               return;
          }    
          if( ( error=myDispatch-> QueryInterface (IID_IHTMLInputHiddenElement,(LPVOID *)&myHtmlInputHiddenElement))!=S_OK)
          {          
               MessageBox("error in query interface of iid_ihtmlinputhiddenelement");
               return;
          }

if( (myHtmlInputHiddenElement->put_value(no_ToSend) )!= S_OK)               //myHtmlInputHiddenElement
          {
               MessageBox("error in putvalue");
               return;
          }

Now in the above through my putvalue i am sending data to
hidden field
I am successfully putting data to it
My problem is when i  retrive data through my asp program
and writing to file
The characters whose ASCII VALUE IS > THAN 256 i am not   able to write to file
My asp code is already written above
 

0
 
PSRISAIHARIAuthor Commented:
The data that its writing is <<#&65021;>> for the values whose ascii value is greater than 256.

Since the data type in vc++ is BSTR(unsigned short) i am
able to send values greater than 256.
Through my vc++ WriteFile i can write unsigned short data
to a file.
But through asp i am not able to write all the data in the
hidden field.
If at all u find simple syntax mistakes in my VC++ code i am showing please ignore it. I have no problem in my vc++
code
sai
0
 
DanRollinsCommented:
There is a chance that you are getting the correct data, but that it is not being written to the file.  One quick test would be to have the asp program pop up a window with the data.

-- Dan
0
 
DanRollinsCommented:
hi PSRISAIHARI,
Do you have any additional questions?  Do any comments need clarification?

-- Dan
0
 
DanRollinsCommented:
hi PSRISAIHARI,
Do you have any additional questions?  Do any comments need clarification?

-- Dan
0
 
griesshCommented:
Dear PSRISAIHARI

I think you forgot this question. I will ask Community Support to close it unless you finalize it within 7 days. You can always request to keep this question open. But remember, experts can only help you if you provide feedback to their questions.
Unless there is objection or further activity,  I will suggest to accept

     "ShaunWilde"

comment(s) as an answer.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
======
Werner
0
 
MindphaserCommented:
Force accepted

** Mindphaser - Community Support Moderator **
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.