Showing posts with label properly. Show all posts
Showing posts with label properly. Show all posts

Saturday, March 31, 2012

Submitting Form to Database

I have an ASP.Net page created with a table I made to look like a form
for our benefit request program. How do I code this properly to send
it to a table in our database.

For the sake of me learning how to do this lets just do short example
like. I have an aspx page with a label for name and a text box where
a user can input their name.

I have a database table called tblName with a column called name where
the submitted names go.

How do I code it so the name is submitted, a confirmation page is
shown and the data goes to the database when I click submit? Any help
is greatly appreciated.

Thanks,
BenIf you look at the ASP.NET QUICKSTART tutorials on the asp.net website, it
has lots of examples like this. QUICKSTARTS also installs as an option with
Visual Studio.
--
--Peter
"Inside every large program, there is a small program trying to get out."
http://www.eggheadcafe.com
http://petesbloggerama.blogspot.com
http://www.blogmetafinder.com
"Ben" wrote:

Quote:

Originally Posted by

I have an ASP.Net page created with a table I made to look like a form
for our benefit request program. How do I code this properly to send
it to a table in our database.
>
For the sake of me learning how to do this lets just do short example
like. I have an aspx page with a label for name and a text box where
a user can input their name.
>
I have a database table called tblName with a column called name where
the submitted names go.
>
How do I code it so the name is submitted, a confirmation page is
shown and the data goes to the database when I click submit? Any help
is greatly appreciated.
>
Thanks,
Ben
>

Submitting Form to Database

I have an ASP.Net page created with a table I made to look like a form
for our benefit request program. How do I code this properly to send
it to a table in our database.
For the sake of me learning how to do this lets just do short example
like. I have an aspx page with a label for name and a text box where
a user can input their name.
I have a database table called tblName with a column called name where
the submitted names go.
How do I code it so the name is submitted, a confirmation page is
shown and the data goes to the database when I click submit? Any help
is greatly appreciated.
Thanks,
BenIf you look at the ASP.NET QUICKSTART tutorials on the asp.net website, it
has lots of examples like this. QUICKSTARTS also installs as an option with
Visual Studio.
--
--Peter
"Inside every large program, there is a small program trying to get out."
http://www.eggheadcafe.com
http://petesbloggerama.blogspot.com
http://www.blogmetafinder.com
"Ben" wrote:

> I have an ASP.Net page created with a table I made to look like a form
> for our benefit request program. How do I code this properly to send
> it to a table in our database.
> For the sake of me learning how to do this lets just do short example
> like. I have an aspx page with a label for name and a text box where
> a user can input their name.
> I have a database table called tblName with a column called name where
> the submitted names go.
> How do I code it so the name is submitted, a confirmation page is
> shown and the data goes to the database when I click submit? Any help
> is greatly appreciated.
> Thanks,
> Ben
>

Wednesday, March 28, 2012

Successful validation still blocks postback

Hello,

I have an ASP.NET site that uses validators on a couple pages. On our
staging servers, the site works properly. When I deploy it to the live
server, however, the pages that have validators will not postback. The
validators do appear to be working properly--they show me an error if
the field is empty, and not if it isn't. I saved the generated HTML
from the staging server and the live server, and discovered that there
were a couple differences in the Javascript code related to validation.
I saved the HTML from the live server, and changed code line-by-line,
and eventually wound up with a page that would postback. So the issue
seems to be the generated HTML.

The staging and live servers are both running Win 2k3, IIS 6, .NET
Framework v1.1.4322. The live server does have an older version of .NET
Framework installed. The properties of the site in IIS are set to
process .aspx pages with the v1.1.4322 dll. The WebUIValidation.js file
appears to be in all the right places. The hosting company re-ran
aspnet_regiis.exe, which has cured mysterious ailments in the past.

Has anybody seen anything like this? Any ideas?

ThanksIts probably the bug in ASP.NET 1.1 SP 1. See this thread:
http://forums.asp.net/739537/ShowPost.aspx

-- Peter Blum
www.PeterBlum.com
Email: PLBlum@.PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

<nospamforjoel@.yahoo.com> wrote in message
news:1118757786.746135.236060@.g44g2000cwa.googlegr oups.com...
> Hello,
> I have an ASP.NET site that uses validators on a couple pages. On our
> staging servers, the site works properly. When I deploy it to the live
> server, however, the pages that have validators will not postback. The
> validators do appear to be working properly--they show me an error if
> the field is empty, and not if it isn't. I saved the generated HTML
> from the staging server and the live server, and discovered that there
> were a couple differences in the Javascript code related to validation.
> I saved the HTML from the live server, and changed code line-by-line,
> and eventually wound up with a page that would postback. So the issue
> seems to be the generated HTML.
> The staging and live servers are both running Win 2k3, IIS 6, .NET
> Framework v1.1.4322. The live server does have an older version of .NET
> Framework installed. The properties of the site in IIS are set to
> process .aspx pages with the v1.1.4322 dll. The WebUIValidation.js file
> appears to be in all the right places. The hosting company re-ran
> aspnet_regiis.exe, which has cured mysterious ailments in the past.
> Has anybody seen anything like this? Any ideas?
> Thanks

Monday, March 26, 2012

Suggested means to cope with commas etc.

G'day,
In a typical 'contact us' type page what is a recommended way to ensure a message text box gets dealt with properly rather than break at comma's etc.

Is it as simple as using server.encodeHTML() on every passed variable? When I do this I still seem to have problems.

GeoffWhy would you break at commas? I don't get the problem.
Sorry. Error was happening when writing a record of the email to a database.

So if I can change my question...

Is there a best-practice' approach to handling commas etc. when writing to database eg:..."insert into myTable message = '" & server.encodeHTML(msg.text) & "'" is the sort of thing that was breaking if a comma existed in the textbox called msg?

Thanks,

Geoff
The commas should not mess it up within the quotes.

If an apostrophe appears within the string ('), then it will close the string and this is what will mess it up.

The best practice is to use Parameters. These will take care of all these issues as well as protect you against SQL injection and a few other problems you may not have noticed yet.