473,787 Members | 2,934 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

grabbing a traditional form value via .net (instead of referencing an object)

I have a contact form that a person submits to the server.

In ASP, you'd make a page, post the form to another page, which would grab
the values and do somethign with them.

in ASP.NET, it appears that you grab the values directly from the form
objects on the postback.

Here's our problem:

We wanted to make a list of radiobutton options. Unfortunately, .net's
datalist and radioButtonGrou p controls produce invalid HTML if you want to
format it in columns and you don't have enough record to populate every
column of every row of the table. So, to remedy this, I am building the HTML
for this list of radio buttons on the codebehind page and passing it to the
aspx page as text for a label.

The problem is that the person that is grabbing the data from the form to
submit it to the database and email can't 'grab' the value of these
radioButtons since they don't 'exist' on the ASPX page until the page is
processed on the server.

Is there a way around this? We're thinking that perhaps we can add a
radioButton to the aspx page in a hidden panel, which will allow the
codebehind to 'see' the radioButotn prior to page rendering. Then, when the
page does render, the radioButtons that do appear can override the value of
the hidden default one. Of course, this seems like a giant hack to me. ;o)

-Darrel
Nov 18 '05 #1
4 1392
Hi darrell,
the hidden default one. Of course, this seems like a giant hack to me. ;o)
The whole thing IS a giant hack. Unfortunately, and I can certainly
sympathize with you in regards to this situation, but you will need to
understand ASP.Net's programming model a good bit better before you can
really make use of it effectively. For example, instead of using a
RadioButtonGrou p for radio buttons, you could certainly use individual
RadioButton Controls in your page.

The rub here, is, of course, you have to produce a product. But it would be
better in the long run if you got to know this much bigger than ASP
programming model before you try to implement it in production. If you're in
a bind, you can access any form field data posted by the client in the
Request.Form collection, regardless of whether the client-side HTML elements
are connected to CodeBehind Controls or not.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"darrel" <no*****@hotmai l.com> wrote in message
news:ud******** ******@TK2MSFTN GP09.phx.gbl... I have a contact form that a person submits to the server.

In ASP, you'd make a page, post the form to another page, which would grab
the values and do somethign with them.

in ASP.NET, it appears that you grab the values directly from the form
objects on the postback.

Here's our problem:

We wanted to make a list of radiobutton options. Unfortunately, .net's
datalist and radioButtonGrou p controls produce invalid HTML if you want to
format it in columns and you don't have enough record to populate every
column of every row of the table. So, to remedy this, I am building the HTML for this list of radio buttons on the codebehind page and passing it to the aspx page as text for a label.

The problem is that the person that is grabbing the data from the form to
submit it to the database and email can't 'grab' the value of these
radioButtons since they don't 'exist' on the ASPX page until the page is
processed on the server.

Is there a way around this? We're thinking that perhaps we can add a
radioButton to the aspx page in a hidden panel, which will allow the
codebehind to 'see' the radioButotn prior to page rendering. Then, when the page does render, the radioButtons that do appear can override the value of the hidden default one. Of course, this seems like a giant hack to me. ;o)

-Darrel

Nov 18 '05 #2
> For example, instead of using a
RadioButtonGrou p for radio buttons, you could certainly use individual
RadioButton Controls in your page.
Well, as you said, I need to produce real product based on what I know. I'm
always up to learning more though!

So, conceptually, what would the solution be if I were to use individual
RadioButton Controls?

Here's what I'm doing:

Grabbing a set of records from a table.
Assigning each record to a radioButton.
Rendering it on the page.
If you're in
a bind, you can access any form field data posted by the client in the
Request.Form collection, regardless of whether the client-side HTML elements are connected to CodeBehind Controls or not.


That's good to know. What is the disadvantage of using this? I'm all for
doing things the 'right way--the .net way' but sometimes the .net way seems
counter-intuitive, or just plain verbose for web development. I know part of
that is just making the mental leap from interpreted code to OOP but there
are times when classic ASP and ASP.NET seem to be at polar opposites of the
web development methodology spectrum when, in the real world, there seems to
be a need for that middle-ground.

-Darrel
Nov 18 '05 #3
> So, conceptually, what would the solution be if I were to use individual
RadioButton Controls?
HTML Radio Buttons are grouped by their name attribute. When several Radio
buttons have the same name, they belong to the same group. The form will
post only ONE value for the entire group, whichever Radio button that is
checked. In the RadioButton WebControl, the GroupName property determines
the name attribute of the RadioButton when rendered on the client. I
wouldn't set them to AutoPostBack, but when the PostBack occurs you could
certainly check their Checked properties. Only one will be true.
That's good to know. What is the disadvantage of using this? I'm all for
doing things the 'right way--the .net way' but sometimes the .net way seems counter-intuitive, or just plain verbose for web development. I know part of that is just making the mental leap from interpreted code to OOP but there
are times when classic ASP and ASP.NET seem to be at polar opposites of the web development methodology spectrum when, in the real world, there seems to be a need for that middle-ground.
Good question, Darrel. There are a good number of reasons why the ASP.Net
programming model was designed the way it was. HTTP is stateless, which
means that, in ASP, you had to build your own routines for maintaining state
in your ASP pages. ASP.Net has state management built right into it. ASP was
a bit too relaxed in its rules, making for some serious spaghetti code out
there (I've had to untangle a good bit of it in the past myself). ASP.Net is
more rigidly structured by nature, and tends to force the developer to
separate presentation code and business logic, which is a very good thing
when it comes to code maintenance. Object-oriented programming is by nature
much better overall than procedural, for quite a few reasons.

As for being "counter-intuitive," that's just a matter of time and practice.
Once you "get it" it becomes entirely intuitive.

Good luck!

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"darrel" <no*****@hotmai l.com> wrote in message
news:eE******** ******@TK2MSFTN GP10.phx.gbl...
For example, instead of using a
RadioButtonGrou p for radio buttons, you could certainly use individual
RadioButton Controls in your page.


Well, as you said, I need to produce real product based on what I know.

I'm always up to learning more though!

So, conceptually, what would the solution be if I were to use individual
RadioButton Controls?

Here's what I'm doing:

Grabbing a set of records from a table.
Assigning each record to a radioButton.
Rendering it on the page.
If you're in
a bind, you can access any form field data posted by the client in the
Request.Form collection, regardless of whether the client-side HTML elements
are connected to CodeBehind Controls or not.


That's good to know. What is the disadvantage of using this? I'm all for
doing things the 'right way--the .net way' but sometimes the .net way

seems counter-intuitive, or just plain verbose for web development. I know part of that is just making the mental leap from interpreted code to OOP but there
are times when classic ASP and ASP.NET seem to be at polar opposites of the web development methodology spectrum when, in the real world, there seems to be a need for that middle-ground.

-Darrel

Nov 18 '05 #4
HTML Radio Buttons are grouped by their name attribute. When several Radio
buttons have the same name, they belong to the same group. The form will
post only ONE value for the entire group, whichever Radio button that is
checked. In the RadioButton WebControl, the GroupName property determines
the name attribute of the RadioButton when rendered on the client. I
wouldn't set them to AutoPostBack, but when the PostBack occurs you could
certainly check their Checked properties. Only one will be true.
Oh...right...I know all of that. That is what I'm doing. I'm making my own
set of radio buttons with the same name in the codebehind and then spitting
it out to the aspx page as text for a label.

The issue is that I can't use the built in controls for RadioButtonList s
since .net spits out invalid HTML when it makes a multi-column table. As
such, the codebehind doesn't see the object , since the object is just a
label that has standard HTML assigned to it in the codebehind.
ASP.Net is
more rigidly structured by nature, and tends to force the developer to
separate presentation code and business logic, which is a very good thing
Well, I agree that conceptually it is a good thing, but I'm also finding
that you can't allow .net to make your presentation for you. It's bad at it.
It tends to make bloated, innaccessible and oft-times invalid markup. Hence,
I'm finding that I end up using a lot of repeater controls (which is still
good) but then at times having to move my presentation back to the
codebehind side so I can build it myself.

I'm sure part of that is me not fully understanding all there is to know
about .net, but there also seems to be clear concensus that .net has a long
way to go before developers fully trust it to handle the presentation side
for us.
As for being "counter-intuitive," that's just a matter of time and practice. Once you "get it" it becomes entirely intuitive.


I'm getting there. Thanks for the help!

-Darrel
Nov 18 '05 #5

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

Similar topics

5
2445
by: Dani | last post by:
Hello everybody, I have some code that disables form elements on body load, but I notice when I hit the "back" button, I need to re-enable the form elements (that is done by clicking on a radial button). Is there any way I can keep the form for disabling every time a user hits the back button and "remember" what elements should be enabled? I was thinking maybe utilizing some referrer thing, but I'm not that good with JS yet. Thanks...
2
4769
by: William Wisnieski | last post by:
Hello Everyone, Access 2000 I have a main form with a continuous subform. On the main form I have a text box that references a field on the subform. What I'd like it to do is show the value in the field of the last record entered on the subform. But what its doing is referencing whatever record the user clicked on last before closing all the forms. Also if the user cleared the subform field, I would like the text box on the main...
8
12106
by: Zlatko Matić | last post by:
There is a form (single form) and a combobox. I want that current record of the form is adjusted according to selected value in the combobox. Cuurrent record should be the same as the value in the combobox. What is the solution? Thank you in advance.
4
4191
by: Baz | last post by:
Hi. I'm new to this VB.Net mullarkey, and I must say it is proving to be a very trying experience. Here is the latest in a long line of problems: The Scenario ========= I am building an MDI application. The first thing it does is to pop up a little logon form which gathers and authenticates an SQL Server
1
4235
by: Kermit Piper | last post by:
Hello, OK, almost there. Here's what I have so far, which handles characters as they're typed in. Could someone please show me how I would loop through all the values that are entered if a block of text was pasted in, and then grab the ascii value(s) that are > 128?: <script type="text/javascript"> function toASCII(s) {
11
3002
by: Rik | last post by:
Hello guys, now that I'm that I'm working on my first major 'open' forms (with uncontrolled users I mean, not a secure backend-interface), I'd like to add a lot of possibilities to check wether certain fields match certain criteria, and inform the user in different ways when the data is wrong (offcourse, this will be checked on posting the data again, but that's something I've got a lot of experience with). Now, offcourse it's...
11
3526
by: ozTinker | last post by:
I'm sure this shouldn't be too difficult, but I lack familiarity with the MS object model. Suppose I have a table "Purchase_Orders" and a form "TEMP" which I am using to look up a customer's orders. The form has a text field named LastName for typing in new orders, but first let's look at the previous orders. Elsewhere on the form is a Office Web Components Spreadsheet version 11.0, which will run a query and show the result list. The...
3
4695
by: bsturg21 | last post by:
Hello, I have a windows form that has a series of linklabels on it, and I need to have each linklabel, when clicked, open a separate windows form that has a single paramter passed into it. The form that has the System.Windows.Forms.LinkLabel controls on it is in a different project and under a different namespace from the file where the LinkLabel_LinkClicked events are, so I can't just do frm.ShowDialog under the LinkClicked method. ...
4
2642
by: Norman | last post by:
I am trying to find a way to implement something like: <FORM name='form1'><TABLE> server scripting loop (php), generates X (a variable number) lines with the 3 fields { <TR><TD><input type='text' name='kminicial'></TD> <TD><input type='text' name='kmfinal' onBlur='document.form1.kmrodados.value=document.form1.kmfinal.value- document.form1.kminicial.value'></TD> <TD><input type='text' name='kmrodados'></TD></TR>
0
9498
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
10363
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...
1
10110
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,...
1
7517
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
6749
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5398
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...
0
5535
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4069
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2894
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.