Solved

HOW TO READ DATA FROM HTML HIDDEN FIELD

Posted on 2001-06-16
13
233 Views
Last Modified: 2013-11-20
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.
0
Comment
Question by:PSRISAIHARI
  • 5
  • 3
  • 3
  • +2
13 Comments
 
LVL 49

Expert Comment

by:DanRollins
Comment Utility
Show the code that is failing and decsribe any error messages and so forth that you see when it fails.

-- Dan
0
 
LVL 9

Expert Comment

by:ShaunWilde
Comment Utility
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
 

Author Comment

by:PSRISAIHARI
Comment Utility
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
 
LVL 49

Expert Comment

by:DanRollins
Comment Utility
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
 
LVL 9

Expert Comment

by:ShaunWilde
Comment Utility
> greater than 256

do you mean string length ?

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

0
 

Author Comment

by:PSRISAIHARI
Comment Utility
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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:PSRISAIHARI
Comment Utility
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
 
LVL 9

Accepted Solution

by:
ShaunWilde earned 100 total points
Comment Utility
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
 
LVL 49

Expert Comment

by:DanRollins
Comment Utility
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
 
LVL 49

Expert Comment

by:DanRollins
Comment Utility
hi PSRISAIHARI,
Do you have any additional questions?  Do any comments need clarification?

-- Dan
0
 
LVL 49

Expert Comment

by:DanRollins
Comment Utility
hi PSRISAIHARI,
Do you have any additional questions?  Do any comments need clarification?

-- Dan
0
 
LVL 11

Expert Comment

by:griessh
Comment Utility
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
 
LVL 6

Expert Comment

by:Mindphaser
Comment Utility
Force accepted

** Mindphaser - Community Support Moderator **
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now