474,047 Members | 3,151 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to process items in response.form collection dynamically?

HI. in asp.net app, I have an xmlDocument that I transform to the client
html. Using xsl I create a few textboxes to capture user input. Each of
these are related to <data> elements in the xmlDoc.

I want to use the Forms collection to post the html form back to an
asp.net page, and process each request.form object (textbox) via an xml
node.value update.

For any given xmlDocument there is an unknown number of items resulting
in textboxes. Each one would, however, have a unique name via their
attributes and that's how I would identify the node.values to update.

Within the new asp.net form I post the html form to, how would I
retrieve each of the items? I'm thinking some kind of for each
statement? But how to assign the name/value pairs etc. dynamically.

Hope this is clear enough! Any examples appreciated.

Thanks.

Kathy

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 17 '05
10 6948
p2p.wrox.com, look up code for Professional VB.NET Chapter 10--on XML--maybe
something there can help you. If not try www.superexpert.com, "ASP
Unleashed" Look at code for Chapter 13.

Both of these deal with XML and are really the extent of what I know but
just haven't used it much.

You can easily iterate through your form posted elements as I have said
before. If all have a unique name, then you can get "NameofElem ent" and
then go get it's value as mentioned before... Do that in a loop using the
count-1 property of the collection.

Inside of that as to what to do with it in XML, John is write--that is an
XML question better directed at an XML group. But maybe the sample code
from one of the books I mentioned might have something you need.

Sorry I can't be of further help.
Shane

"KathyB" <Ka**********@a ttbi.com> wrote in message
news:75******** *************** ***@posting.goo gle.com...
My html form is a set of user instructions steps. For each
<data_collectio n> element, for example, my xsl turns that into an
<input type=text name="the unique name attribute defined in the base
xml doc"> box in the html form (I would post it, but it's really quite
large). AND, I don't have the html script yet!!! but it's just a
simple post to an aspx page (e.g., process_dom.asp x).

The only "changes" the user is allowed to make are via these text
boxes. When the user is done, they click a Submit button. The submit
javascript then opens an aspX page (hidden from the user), where I
would use code to load the original xml doc and that's where I need to
do node.value changes FOR EACH TEXTBOX INPUT before saving the entire
DOM.

Again, because these instruction docs have an unknown number/type
(different elements such as <measurement> and <data_collectio n> of
name/value pairs, that's where I'm needing the help! I think what
you're giving me is certainly the right track, I'm just not able yet
to translate it into the code I need.

For example, a request.form collection ends up having 2 pairs from two
html textboxes name="one", name="two".

For each, I need to set a variable name so I can use that in an xpath
to get to the right DOM node (yes?).

Dim xElem As XmlElement =
xDoc.SelectSing leNode("//measurement[@name='" & varName & "'")

Then I could do a node.value = "value of the name/value pair here".

Move onto the next name/value pair, set the varName variable, etc.

Hope this helps clarify...I truly, truly appreciate your sticking with
me on this!!!

Thanks.
Kathy
"John Saunders" <jo***********@ surfcontrol.com > wrote in message

news:<e9******* *******@tk2msft ngp13.phx.gbl>. ..
"KathyB" <Ka**********@a ttbi.com> wrote in message
news:75******** *************** *@posting.googl e.com...
Hi again. Sorry but I'm still confused at how to do this exactly.


That makes two of us. :-)
I
have an html form (resulting from a transformed xml document). Within
the form I will have an unknown set of name/value pairs dependent on
how many of a certain element I have in the source xml (e.g.,
<measurement> or <data_collectio n>.


Ok. BTW, maybe you said this before, but what kind of HTML elements will
contain the name/value pairs from the XML file? Also, I want to make sure we're both talking about an .aspx page?
When I post the html form, my script opens an asp.net page


Ok, now I'm confused.

When you say "post the html form", I presume you mean that you click a
button or something to submit the form? So, what script are you talking
about? Are you referring to a "<script runat=server />" block in the ..aspx page, or perhaps you're referring to the codebehind?

In those cases, the script _is_ the asp.net page. It doesn't open it.
and I need
to save the xml elements back into the DOM.


Ok, which DOM are you talking about? Do you mean that you need to update the original XML file?
I figured the best/easiest
way to do that was the request.forms collection (per other posts I've
had).

But to be dynamic (unknown number of elements, but each with a unique
"name" attribute), in English I want to:

For each name/value pair in the request.form collection, I need to set
an xpath expression pointing to the "name" fo the name/value pair,
then update the name.value of the xpath to the value of the name/value
pair.

See what I mean?


Maybe. You can iterate through the Request.Form collection in the same way you iterate through the NameValueCollec tion in the example I gave. This is because Request.Form _is_ a NameValueCollec tion:

Dim aName as String
Dim aValue as String
For Each aName in Request.Form.Al lKeys
aValue = Request.Form(aN ame)

' Set the xpath expression pointing to aName then
' update the name.value of the xpath to the value of aValue
Next
Thanks for responding. Kathy


I hope I'm getting warmer. BTW, if this gets further into XML, you'll have to find someone else to help out - I haven't done much with XML yet.
--
John Saunders
Internet Engineer
jo***********@s urfcontrol.com

"John Saunders" <jo***********@ surfcontrol.com > wrote in message

news:<eg******* *******@TK2MSFT NGP12.phx.gbl>. ..
> "Kathy Burke" <ka**********@a ttbi.com> wrote in message
> news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
> > John, could you possibly show me a little example?
> > Thanks.
> >
>
> Kathy, if I understand you correctly (and I think maybe I don't), you
want
> to create a set of name/value pairs at one point in your code (like,
> Page_Load), and use it later in the same request (like, in a Click

event > handler). You can do it like this:
>
> ' Let's assume we have a DataReader returning rows with two fields -
> "TheName" and "TheValue".
> ' We can put them in a variable as follows:
>
> Private NamesAndValues as New
> System.Collecti ons.Specialized .NameValueColle ction()
>
> Private Sub Page_Load(sende r as object, e as EventArgs)
> If Not Page.IsPostBack Then
> ' Somehow get the DataReader, then:
>
> While reader.Read()
> NamesAndValues. Add(reader.GetS tring("TheName" ),
> reader.GetStrin g("TheValue") )
> End While
> End If
> End Sub
>
> ' Later:
> Private Sub btnOk_Click(sen der as Object, e as EventArgs)
> ' We can get the value for a particular name
> Dim aValue as String = NamesAndValues( "aName")
>
> ' Or we can loop through them all
> Dim aName as String
>
> For Each aName in NamesAndValues. AllKeys
> aValue = NamesAndValues( aName)
> Next
>
> End Sub
>
> I hope that helps.

Nov 17 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

77
4690
by: Charles Law | last post by:
Hi guys I have a time critical process, running on a worker thread. By "time critical", I mean that certain parts of the process must be completed in a specific time frame. The time when the process starts is not especially important, but it must be complete within a small number of seconds. The operations I am performing do not take a long time (hundreds of milliseconds), but as each part of the process is complete, my worker thread...
0
2299
by: Jason Ferree | last post by:
I posetd this in one group, but got no response, so I'll try it in this one. I am trying to loop through all messages in the inbox. To do something, in my case, look for and save attachments. It is telling me that items is not a collection. I've tried everything I can think of, I've even copied the code from a few sources (had to add specific OOM in front of method names), Including Sues book, some code from www.outlookcode.com, and...
1
392
by: Kathy Burke | last post by:
HI. in asp.net app, I have an xmlDocument that I transform to the client html. Using xsl I create a few textboxes to capture user input. Each of these are related to <data> elements in the xmlDoc. I want to use the Forms collection to post the html form back to an asp.net page, and process each request.form object (textbox) via an xml node.value update. For any given xmlDocument there is an unknown number of items resulting in...
7
2766
by: Keith Patrick | last post by:
After completely giving up on finding some way in my ASP.Net app to take a query string URL and redirect to it as a POST instead, I went with a system like so: Upon "redirection," all the QueryString pairs are placed in HttpContext.Current.Items and retrieved with a wrapper for Request.Params that includes checks there. This works in general instances, but one problem has come up that has me stuck: since the stuff is in the context and...
3
1510
by: Linda | last post by:
Greetings! In order to keep better track a form with several combo-boxes, I've subclassed the ones that need to change in response to events on other controls on the form. An example of a subclassed combo box: <code> Public Class byte13ComboBox Inherits System.Windows.Forms.ComboBox Private comboItems() As String = {"a (Numbered)", _
3
5079
by: Will Chamberlain | last post by:
I am running into a strange error when I try debugging my current application. A form loads up with a dynamically-populated textbox full of software titles. Upon selection of a software title and pressing 'GO' a checkboxlist is displayed with the users who use the current software. The checkboxlist is bound to a dataset named "DataTable" and has the DisplayMember set to "Employee" and the DataValue set to "ID", like the following: ----...
1
7319
by: Daniel Gormley | last post by:
What I have is a form that is dynamically generated based on which database table its calling. Therefore, the number of category.name.count can be different. So I have this form generated and say with x amount of input boxes.. I enter data in the boxes and submit. The data submitted is needing to be placed into an array for insert into a database.
2
4897
by: Milsnips | last post by:
hi there, i have the following HTML code: -------------------------- <asp:DropDownList id="hddList" runat="server"> <asp:ListItem Value="1">Item 1</asp:ListItem> <asp:ListItem Value="2">Item 2</asp:ListItem> <asp:ListItem Value="3">Item 3</asp:ListItem> <asp:ListItem Value="4">Item 4</asp:ListItem> <asp:ListItem Value="5">Item 5</asp:ListItem>
14
18827
by: Paul_Madden via DotNetMonster.com | last post by:
Basically I have a listbox to which I add simple STRING items- I have a progress bar which I increment whenever I populate another portion of the complete set of items I wish to add. What I observe is that as more and more are added, population of the list box takes longer and longer. ie the first 10th of the item set are added much much quicker than the last 10th. THis occurs with about 40,000 listbox items. My worry is the listbox may...
4
1720
by: TS | last post by:
In my production exceptions i get an email with all the form elements and their values to debug. the controls that have a blank value are not seen and it makes my debug job harder (was the control's value blank or was it set invisible on server so its not in the html). how do i access all controls whether blank or not? thanks
0
10548
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10349
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
12148
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
11604
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
12036
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10316
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8701
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6662
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
3976
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.