Showing posts with label users. Show all posts
Showing posts with label users. Show all posts

Saturday, March 31, 2012

text box editing

I have a text box where users can enter a reference number. This can be a varchar. I want to use this in a SQL lookup so I want to check for characters that may cause issues in the SQL statement . / _ % and such and escape them so they can still search by these fields? Any suggestions out there?You can use a regular expression to remove characters you don't want like so:

Dim badCharReplace As Regex = New Regex("([<>""'%;()&])")
Dim s As String = badCharReplace.Replace(psInput, "")

Text box reading old value

Hi i am trying to create a simple page that would allow users to edit there infromation that is stored on them,

It loads the information from the database fine and puts it into the textbox's but then on the "update" button it doesnt get the changed values

e.g

if the textbox was set on the page load to "bren" and then i changed it on the page to be "Hello" when i execute the onlclick function of the button it still reads as "bren"

using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Data.Odbc;public partialclass user_userDetails : System.Web.UI.Page{protected void Page_Load(object sender, EventArgs e) {if (!HttpContext.Current.User.Identity.Name.Contains(ConfigurationManager.AppSettings["siteGSTPrefix"])) {string userGuid = HttpContext.Current.User.Identity.Name; OdbcConnection detailsCon = sqlconnect.Connect(); OdbcCommand detailsCom =new OdbcCommand("SELECT tbl_usr.Username,tbl_usr_info.first_name,tbl_usr_info.second_name,tbl_usr_info.address_line_1,tbl_usr_info.address_line_2,tbl_usr_info.address_line_3,tbl_usr_info.post_code,tbl_usr_info.home_phone,tbl_usr_info.work_phone,tbl_usr_info.email_addy FROM tbl_usr INNER JOIN tbl_usr_info ON tbl_usr.usr_guid = tbl_usr_info.usr_guid WHERE tbl_usr.usr_guid='" + userGuid +"'", detailsCon); OdbcDataReader detRead = detailsCom.ExecuteReader();while (detRead.Read()) { userNote.Text ="Your Password is not displayed for security!"; userName.Text = detRead["Username"].ToString().Replace("#@dotnet.itags.org.","'"); fName.Text = detRead["first_name"].ToString().Replace("#@dotnet.itags.org.","'"); sName.Text = detRead["second_name"].ToString().Replace("#@dotnet.itags.org.","'"); aD1.Text = detRead["address_line_1"].ToString().Replace("#@dotnet.itags.org.","'"); aD2.Text = detRead["address_line_2"].ToString().Replace("#@dotnet.itags.org.","'"); aD3.Text = detRead["address_line_3"].ToString().Replace("#@dotnet.itags.org.","'"); pCode.Text = detRead["post_code"].ToString().Replace("#@dotnet.itags.org.","'"); hPhone.Text = detRead["home_phone"].ToString().Replace("#@dotnet.itags.org.","'"); wPhone.Text = detRead["work_phone"].ToString().Replace("#@dotnet.itags.org.","'"); eAddy.Text = detRead["email_addy"].ToString().Replace("#@dotnet.itags.org.","'"); } detRead.Close(); detailsCon.Close(); }else { Response.Redirect(FormsAuthentication.LoginUrl); } }protected void update_click(object sender, EventArgs e) {string userGuid = HttpContext.Current.User.Identity.Name;string passSettings =string.Empty; Response.Clear();if(userPass.Text.ToString() !="" && userPass.Text.ToString() !=null) { passSettings =" , tbl_usr.Password = '" + userPass.Text.ToString().Replace("'","#@dotnet.itags.org.") +"'"; } OdbcConnection detCon = sqlconnect.Connect(); OdbcCommand upCom =new OdbcCommand("UPDATE tbl_usr SET tbl_usr.Username = '" + userName.Text.ToString().Replace("'","#@dotnet.itags.org.") +"' " + passSettings +" WHERE tbl_usr.usr_guid = '" + userGuid +"'", detCon); upCom.ExecuteNonQuery(); OdbcCommand upComInfo =new OdbcCommand("UPDATE tbl_usr_info SET tbl_usr_info.first_name = '" + fName.Text.Replace("'","#@dotnet.itags.org.") +"' , tbl_usr_info.second_name = '" + sName.Text.Replace("'","#@dotnet.itags.org.").Trim() +"' , tbl_usr_info.address_line_1 = '" + aD1.Text.ToString().Replace("'","#@dotnet.itags.org.") +"' , tbl_usr_info.address_line_2 = '" + aD2.Text.ToString().Replace("'","#@dotnet.itags.org.") +"' , tbl_usr_info.address_line_3 = '" + aD3.Text.ToString().Replace("'","#@dotnet.itags.org.") +"' , tbl_usr_info.post_code = '" + pCode.Text.ToString().Replace("'","#@dotnet.itags.org.") +"' , tbl_usr_info.work_phone = '" + wPhone.Text.ToString().Replace("'","#@dotnet.itags.org.") +"' , tbl_usr_info.home_phone = '" + hPhone.Text.ToString().Replace("'","#@dotnet.itags.org.") +"' , tbl_usr_info.email_addy = '" + eAddy.Text.ToString().Replace("'","#@dotnet.itags.org.") +"' WHERE tbl_usr_info.usr_guid = '" + userGuid +"'", detCon); upComInfo.ExecuteNonQuery(); userNote.Text ="Your details have been updated"; }}


Thanks for your help in advance

Dan

your update_click is happening after the page_load. try changing the code you have in page_load to page_prerender and see if you are good to go.


i have treid to user it with IsPostBack but it doesnt work,

i didnt think that Page_load was re run when u clicked on a button and ran the function

Dan


Fixed it now thanks changed it to a !IsPostBack and it now works thanks

Wednesday, March 28, 2012

Text field validation

I'm using SQL Server and ASP.Net. I would like the users when typing in
their passswords to enter in:
1. At least 6 characters
2. At least 1 number
3. At least 1 letter.

I have looked at the validator controls and can't find a example.
Any ideas or articles?

Thanks.

ErikUse the regular expression validator and enter the correct validation
expression. There is a help file accessible from the ValidationExpression
property dialog box that is a tutorial on regular expressions.

"Big E" <nospam@.nospam.com> wrote in message
news:eexE5uN9DHA.2028@.TK2MSFTNGP10.phx.gbl...
> I'm using SQL Server and ASP.Net. I would like the users when typing in
> their passswords to enter in:
> 1. At least 6 characters
> 2. At least 1 number
> 3. At least 1 letter.
> I have looked at the validator controls and can't find a example.
> Any ideas or articles?
> Thanks.
> Erik
I can't find anything that will show me how to force users to enter at least
1 letter and 1 number.

Thanks.

Erik

"Scott M." <s-mar@.BADSPAMsnet.net> wrote in message
news:ei7D67N9DHA.2308@.TK2MSFTNGP11.phx.gbl...
> Use the regular expression validator and enter the correct validation
> expression. There is a help file accessible from the ValidationExpression
> property dialog box that is a tutorial on regular expressions.
>
> "Big E" <nospam@.nospam.com> wrote in message
> news:eexE5uN9DHA.2028@.TK2MSFTNGP10.phx.gbl...
> > I'm using SQL Server and ASP.Net. I would like the users when typing in
> > their passswords to enter in:
> > 1. At least 6 characters
> > 2. At least 1 number
> > 3. At least 1 letter.
> > I have looked at the validator controls and can't find a example.
> > Any ideas or articles?
> > Thanks.
> > Erik
To make the textbox required AND to have the data follow a specific pattern,
you need to add 2 validators to form (1 is a RequiredFieldValidator and 1 is
a RegularExpressionValidator) and have BOTH of them point to the textbox as
the ControlToValidate.

Now, users will be required to fill in data AND the data they fill in will
have to follow the regular expression you set up.

"Big E" <nospam@.nospam.com> wrote in message
news:uGfugHO9DHA.2368@.TK2MSFTNGP11.phx.gbl...
> I can't find anything that will show me how to force users to enter at
least
> 1 letter and 1 number.
> Thanks.
> Erik
>
> "Scott M." <s-mar@.BADSPAMsnet.net> wrote in message
> news:ei7D67N9DHA.2308@.TK2MSFTNGP11.phx.gbl...
> > Use the regular expression validator and enter the correct validation
> > expression. There is a help file accessible from the
ValidationExpression
> > property dialog box that is a tutorial on regular expressions.
> > "Big E" <nospam@.nospam.com> wrote in message
> > news:eexE5uN9DHA.2028@.TK2MSFTNGP10.phx.gbl...
> > > I'm using SQL Server and ASP.Net. I would like the users when typing
in
> > > their passswords to enter in:
> > > 1. At least 6 characters
> > > 2. At least 1 number
> > > 3. At least 1 letter.
> > > > I have looked at the validator controls and can't find a example.
> > > Any ideas or articles?
> > > > Thanks.
> > > > Erik
> >

Saturday, March 24, 2012

Text property values in Textboxes in ASP.NET

I have a website designed where users can enter a large amount of data into a mutlirow textbox. This can be stuff that has line breaks and such. The user can enter this information and it looks OK if I retrieve it from my SQL Database. When I retrieve it into a Windows Forms text box...it looks rather garbled. Is there a way to make them both look the same? I fear that if users muck with the values in my Windows Form support app, it will screw up the display for the web users.

Line breaks on an HTML page can only be achieved by using the <br /> tags, therefore a piece of text with paragraphs will just run together when it is pulled from the DB to the web page. What I do to fix this is I created a function called FormatHTML() that takes a string input and replaces all carriage returns with a "<br />" tag. The function does something like this...
TheString.Replace(CHR(10), "<br />")
You'll need to import Microsoft.VisualBasic to do that.


But the text from the HTML text boxes is not returning HTML tags in the text...actually it appears to be ASCII or something like that. That is what is baffling. To add to my story. I took a text box in Windows Forms on a record that was added from the web. Made complete changes in the multi line text box and saved it. When I re-opened it it looked like it got changed again and had little boxes where line feeds and carriage returns would be and munged it together into a single paragraph.

In SQL Server these text fields are bunched together and where carriage return and linefeeds would be it shows boxes. So if I create these text values in multiline text boxes on the web they look normal like this:
Benefits

This has the following values:

1. Data
2. Data 2
If I open up that value after it has been stored in the database it is all mashed together with boxes for carriage returns and linefeeds. If I edit it in a Windows Forms text box and make it look normal, and then submit that back to the database. The web looks like it does above but going back into the Windows Form text boxes returns it to the funky display. What is up with this??


Nobody??

Thursday, March 22, 2012

textBox

in C# for asp. i have a textbox, and at the point of doing an INSERT to my
table, it is cutting it off at the point where end users press Return (the
next line).

in other words, in a multiline textbox which allows up to 4000 characters,
if the end users presses a key to go to the next line it doesn't add the next
line to sql?

stringbuilder has my comments something like:
string myComments = "123456789 are my numbers/nBut here the line is broken"
/n is where it stops. i'm sure doing a replace for this will fix it, but is
there a better way?How do you know it is cutting off your string? Are you looking at in in
Enterprise Manager or when your content renders?

"ae" <ae@.discussions.microsoft.com> wrote in message
news:CF42C75A-C2ED-4169-BE86-B0928AE3EBCC@.microsoft.com...
> in C# for asp. i have a textbox, and at the point of doing an INSERT to
> my
> table, it is cutting it off at the point where end users press Return (the
> next line).
> in other words, in a multiline textbox which allows up to 4000 characters,
> if the end users presses a key to go to the next line it doesn't add the
> next
> line to sql?
> stringbuilder has my comments something like:
> string myComments = "123456789 are my numbers/nBut here the line is
> broken"
> /n is where it stops. i'm sure doing a replace for this will fix it, but
> is
> there a better way?
Both.

In enterprise Mgr. i only get the first 16 characters. I did two changes
and it fixed it, i had the field type set as text with the default of 16.
that might of caused it, but I doubt it since it only had 4 characters at one
point.

it's corrected now, I changed the field to nvarchar from text in sql, and
with a stringbuilder used something like: strInput = Replace("\n", (" ")
and did another for the "\r". All is well.

"Peter Rilling" wrote:

> How do you know it is cutting off your string? Are you looking at in in
> Enterprise Manager or when your content renders?
> "ae" <ae@.discussions.microsoft.com> wrote in message
> news:CF42C75A-C2ED-4169-BE86-B0928AE3EBCC@.microsoft.com...
> > in C# for asp. i have a textbox, and at the point of doing an INSERT to
> > my
> > table, it is cutting it off at the point where end users press Return (the
> > next line).
> > in other words, in a multiline textbox which allows up to 4000 characters,
> > if the end users presses a key to go to the next line it doesn't add the
> > next
> > line to sql?
> > stringbuilder has my comments something like:
> > string myComments = "123456789 are my numbers/nBut here the line is
> > broken"
> > /n is where it stops. i'm sure doing a replace for this will fix it, but
> > is
> > there a better way?
>

textbox

how can i select textbox ?
i have a dictionay . users search the words and how can i select textbox for next search .
for ex .
i search for Hello ====> Greetting ,......
when the search finished the textbox test going to blue ==> Hello
and when user click on textbox the textbox is going to empty


Could you please clarify what you are trying to do more ? I was unable to understand what you are trying to do !!
regards

Hi. I've read your message several times. Maybe its due to the numerous typos but each time, I think you mean something else: changing the font style of a word found inside of the text in a textbox, setting focus and selecting the entire textbox, changing the style of the entire textbox.

Please restate the problem and take the time to reread it before posting so that you know its clear.


sorry for confusing .
i want to when user searched a thing like hello and when the queryexecute the textbox is going to highlight and when he want to insert anew search the textbox going to empty .

after executing query , you must changeforecolor property of textbox to any color you want. In order to emptytextbox when user click on textbox , you can use javascript, addingjavascript to asp textbox control by usingattributes property of textbox control in page_load event:
txtwords.Attributes.Add("onClick","this.value=''");
Hope this will helping you solving your problem .

Tuesday, March 13, 2012

textBox

in C# for asp. i have a textbox, and at the point of doing an INSERT to my
table, it is cutting it off at the point where end users press Return (the
next line).
in other words, in a multiline textbox which allows up to 4000 characters,
if the end users presses a key to go to the next line it doesn't add the nex
t
line to sql?
stringbuilder has my comments something like:
string myComments = "123456789 are my numbers/nBut here the line is broken"
/n is where it stops. i'm sure doing a replace for this will fix it, but is
there a better way?How do you know it is cutting off your string? Are you looking at in in
Enterprise Manager or when your content renders?
"ae" <ae@.discussions.microsoft.com> wrote in message
news:CF42C75A-C2ED-4169-BE86-B0928AE3EBCC@.microsoft.com...
> in C# for asp. i have a textbox, and at the point of doing an INSERT to
> my
> table, it is cutting it off at the point where end users press Return (the
> next line).
> in other words, in a multiline textbox which allows up to 4000 characters,
> if the end users presses a key to go to the next line it doesn't add the
> next
> line to sql?
> stringbuilder has my comments something like:
> string myComments = "123456789 are my numbers/nBut here the line is
> broken"
> /n is where it stops. i'm sure doing a replace for this will fix it, but
> is
> there a better way?
Both.
In enterprise Mgr. i only get the first 16 characters. I did two changes
and it fixed it, i had the field type set as text with the default of 16.
that might of caused it, but I doubt it since it only had 4 characters at on
e
point.
it's corrected now, I changed the field to nvarchar from text in sql, and
with a stringbuilder used something like: strInput = Replace("\n", (" ")
and did another for the "\r". All is well.
"Peter Rilling" wrote:

> How do you know it is cutting off your string? Are you looking at in in
> Enterprise Manager or when your content renders?
> "ae" <ae@.discussions.microsoft.com> wrote in message
> news:CF42C75A-C2ED-4169-BE86-B0928AE3EBCC@.microsoft.com...
>
>

TextBox - Database

Hi All

I have got a registration form..where new Users create the new user IDs...

I just want to check whether the username exists in the database as soon as the user leaves the textbox .

Please help.

Thanks

Asif Ali.

Are you using ASP.NET 2.0 Membership?

Or are you doing things yourself in a SQL table?


HI there

I m doing thing son my own on access database.

Thanks

Asif Ali.


TextBox - Database

Hi Kaushal

U havent seen my question properly.

And also in future please abstain from answering my Q's.

Thanks

Asif.


acube82:

Hi Kaushal

U havent seen my question properly.

And also in future please abstain from answering my Q's.

Thanks

Asif.

oh... i am so so so so so sorrryyy... if you have read the sample code which i have posted before... that was written in btnLogin_Click event... (but we should have that much knowledge that we can write this code event in textbox_chanage event with autopostback tru for textbox)... the code was about select query run against database which would return the datareader if there would be any user in the database with the same name (by checking reader.hasrows) other wise ... it will go to goto label "invaliduserpass" (we should have that much common knowledge that we can change it to msg like "user name already exists..".. anyway... your quote posted will be taken care of in future... thanx..


Ahh, did you get an answer to your question?

Basically (as I think was stated above)... you'd just want to run a SQL query against you're table to see if the username already exists... if you need help with that let me know :)


Since, you want that if the user exists or not as soon as the user leaves the textbox you can make use of AJaX calls. If you are using ASP.NET 2.0 then you can use client callbacks. Using AJAX your page won't refresh and you will know whether the user exists or not. Let me know if you need further details.


Hi...Azam...

I m a beginner..So not into AJAX at the moment.

If U can help me out, will be highly appreciated.

Thanks

Asif Ali.