validate web form entries via textbox again in the C# (code-behind) code again - yes or no??????

I have requiredfieldvalidators, comparevalidators and a regualarexpressionvalidator for the email on my login form for the textboxes. My question is do I have to check in the C# to make sure the textboxes have values and if so what does a experienced programmer think of my code. What would you change??? Are the if statements the way to go??? Thanks for making me a better coder................newbie

protected void LoginButton_Click(object sender, EventArgs e)


string emailAddress = String.Empty;

string password = String.Empty;

if (!String.IsNullOrEmpty(TextBoxEmailAddress.Text))


emailAddress = TextBoxEmailAddress.Text;



if (!String.IsNullOrEmpty(TextBoxPassword.Text))


password = TextBoxPassword.Text;


string userName = Membership.GetUserNameByEmail(emailAddress);

MembershipUser user = Membership.GetUser(userName);

user.IsApproved = true;


bool authenticationStatus = Membership.ValidateUser(userName, password);

if (authenticationStatus)


//TODO: Set create cookie to true, research a little more.

FormsAuthentication.RedirectFromLoginPage(userName, false);




LiteralErrorMessage.Visible = true;



10/6/2006 5:12:55 PM 93655 articles. 6 followers. Follow

1 Replies

Similar Articles

[PageSpeed] 16
Get it on Google Play
Get it on Apple App Store


You don't need this as it is already done for you. As long as you have CausesValidation = true (the default) for the control causing the postback and you have your validator controls, you should be ok.

 The validation controls always perform validation checking in server code. However, if the user is working with a browser that supports DHTML, the validation controls can also perform validation using client script. With client-side validation, any errors are detected on the client when the form is submitted to the server.

10/8/2006 5:07:19 AM

Similar Artilces:

Web Forms Designer error
Hi, The web forms designer keeps adding things in a generated InitializeComponent() method. I believe these things shouldn't be there because I've made a new webform with the same code that doesn't add the same stuff. Is there anyway I can see the Web Designer code? Thanks. Just expand out the hidden #region. It is labeled Web Form Designer CodeStarting with ASP.NET 2.0? Look at:Programming Microsoft Web Forms My Blog...

how to change these windows form code to web form code?
hi, i'm a beginner of c#,i want to know how to change these windows form code to web form code //////////// private void buttonSign_Click( object sender, System.EventArgs e) { //get original message as byte array byte[] messagebytes = Encoding.UTF8.GetBytes( textOriginalMessage.Text); //create digest of original message using SHA1 SHA1 sha1 = new SHA1CryptoServiceProvider(); byte[] hashbytes = sha1.ComputeHash(messagebytes); //display hash bytes in hex format StringBuilder sb = new StringBuilder(); for (...

referencing textboxes on web forms using code behind
 Hello: On my web form I have several text boxes named from textbox1 to textbox30. How do I "reference" these text boxes in code behind ""? Say i wish to write a for loop. for i = 1 to 30 textbox[i].text.length>0 stmt... next i How do I code this part? You can get idea from following link to click “Mark as Answer” on the post If you get answer from this post(s) ! Try the FindControl method.For i = 1 To 30 Dim txt As...

how can i convert code behind web forms pages to inline code pages
hi all of you, I have a problem, a have registered a free space at Brinkster , so i can just upload my files there one by one, but can not install my web application directly, and i have to upload my projects there, so one way is o convert all my VS.NET web application which is code behind, convert that into inline code, so how can i do that Thanks in advanceWarm Regards,Prajesh Kumar JhaE-MAIL : Convert from Code-Behind to Code-Inline: Darrell Norton, MVPDarrell Norton's BlogPlease m...

hei guys, i need help on my application, i'm using C#.NET as front-ed and SQL as back-end, aside from a datagrid, i want to display my data using textboxes and not a datagrid, i can do it using Visual Basic 6 but since i'm a newbee at C#.NET i don't know how to do it, specially the codes, can anyone help me with it? thank you in advance! If you are doing windows development, i would suggest using 'DataForm wizard' (Use Solution Explorer-->Rightclick project-->Add new Item-->New DataForm). It will guide you through steps. If you are doing web apps. Use quickstart to learn them. h...

How can I coding --> auto refreshing Crystal report via>web form
please help me I must show the report(real time) that data come from database --> (data are from another program) User open my webpage for looking the report-->update data How can I set report automatic. --> automatic refresh<----- thanks so much If your report is using the CrystalReportViewer, and you are not exporting the report to PDF or Excel, I would simply set a META Refresh in the header. Here is a reference: This will cause the page to reload from the server at a specified interval....

how to call controls of web control form in coding of other forms?
hello everyone i have one problem i have created one webcontrol shoppingcart in which there are two labels one of qty and other of amt which are initially enable =falsenow on other page(aspx page) i have one txtbox of qty as txtqty i want tat as soon as user enters qty txtqty and clicks on add cart button it shd be display d value in lblqty of web control shopping cart make sure i m using datalist on aspx page so give me suggestions on tat basis and my coding is in vb. plz give ur suggestions as fast as possible. Neeti what do you mean by webcontrol.... it this user control or normal ...

validate Textbox in Web User Control from web form?
ASP.NET 2.0 I have a web user control that contains a textbox.  I need to add some validation (like requiredfieldvalidator, comparevalidator, etc). I would normally add the validator to my web user control by placing the validator next to my textbox.  However, I need the validation message somewhere else on my web form, not near the user control. So how would I associate a validation control on my web form with the text box inside my web user control?  Can this be done; any alternatives out there? Thanks!   The error message should occur wherever you place the vali...

Help C# Web Form Code
Hello -  I need some help here. My debugger kept on telling me "cannot implicity convert type 'System.Web.UI.Control' to ''System.Web.UI.WebControls.Label" ................. at this line lblTest = Page.FindControl("lblTest"); And i can't seem to know why ... Please help  1 public void Page_Load(object sender, EventArgs eArgs) 2 { 3 // now we can dynamically change our injected controls 4 // (though we do still need to "find" them first) 5 System.Web.UI.WebControls.Label lblT...

How to Make Web Forms from other Web Forms
In putting together an ASP.NET application for a biz application, we have come to the point where there are three different types of basic forms which have, for the most part, been perfected. Now its is a matter of cloning those forms for various uses and modifying or adding code to suit the particular need. Copy and paste works OK, but there is a lot of changing of certain words, etc. Is there a way in ASP.NET to take these basic forms, turn them into classes or templates, create forms from them, then add or overwrite code? ? (Anybody who is a Vis Fox Pro programmer would know imme...

Web forms and mobile web forms
Hey everyone, I am looking to develope a web site that depending on the device connecting to it, it will display a certain page. In this case im looking to create a web and wap version of the same project. I have the Web forms version finished using ASP.NET and C# and I am wondering how to create the mobile web form and incorporate it in the project. In the project folder, can I just add a mobile web??? But what about displaying device specific pages?? Cheers -Dudach Yes, you can add mobile web forms and controls to your Web Application project. No problem. For device/br...

Use datastore in Web form code-behind
I am developing a new web application. I have some reports in old legacy system that are written in PB but have to migrate to web. So I migrate the old dw by Datawindow Designer first. And I decide to instance a datastore in web form code-behind, set its datawindow object and retrieve, then save the output as pdf or excel and redirect the saved file back to the browser. The following is the piece of C# codes: Sybase.DataWindow.DataStore ds = new Sybase.DataWindow.DataStore(); this.oleDbConnection1.Open(); Sybase.DataWindow.AdoTransaction tran = new Sybase.DataWindow.AdoTransa...

For interrupting.web form Resized by position of the div : if div can't dispaly all (such as only top part , then web form heithten the heght),resize the web form
Web Form Resized by position of the div : if div can't dispaly all (such as only top part , then web form heithten the heght),resize the web form ! Because of my pool English, if you can't see , I will explain more ! ThanksGambler is the real life I guess you mean when form grows it also grow parent div element. This is normal. If you want div to stay fixed size and rather clip the form and maybe show a scrollbar, look at overflow property in CSS.Thanks------------------------------------------------------------This posting is provided "AS IS" with no warranties, and confers no ...

Web Form embedded in another Web Form
Hi,  I have programmed a Web Form which acts like a scientific calculator. I would like to embedd this calculator in the upper left hand corner of another accounting Web Form. I don't want to host the calculator on the same server as the accounting page. I.e. I want them to have distinct URLs. Classically, I would do this using frames, but is there a better way using ASP? Is there some sort of Panel which can display the webpage at a specific URL which I can just drag onto my accounting Web Form? Thanks,  P1000   Frames are the only way to embed a webform inside ano...

calling a web form from another web form
I would like to know what is the best way to open a web form from another web form. I would like to call it from a button control. Thanks Well, if I've grasped your question right, there are many methods to do that: 1)Response.Redirect > To navigate to another page from code and is equal to clicking a hyperlink. I suggest this as I think it's closer to your question. 2)Server.Transfer > This ends the current web form and begins a new web form. It's usable when you want to pass some variables i.e (Label1.Text) to the next immediate page. It's not safe though and not used to send p...

Web resources about - validate web form entries via textbox again in the C# (code-behind) code again - yes or no?????? -

Looking at the code behind our three uses of Apache Hadoop - Facebook
Facebook Engineering hat eine Notiz mit dem Titel Looking at the code behind our three uses of Apache Hadoop geschrieben. Du kannst den vollständigen ...

How Heartbleed Works: The Code Behind the Internet's Security Nightmare
By now you've surely heard of Heartbleed, the hole in the internet's security that exposed countless encrypted transactions to any attacker who ...

Anatomy of an interactive: a look at the code behind our Second Screen
... and Paralympics coming to town, this presented the perfect opportunity to try it on. Being mainly responsible for the client-side code, I'll ...

How Heartbleed Works: The Code Behind the Internet's Security Nightmare
By now you've surely heard of Heartbleed, the hole in the internet's security that exposed countless encrypted transactions to any attacker who ...

Resources last updated: 12/7/2015 9:05:15 AM