Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 26th, 2005, 03:52 AM
Authorized User
 
Join Date: Feb 2005
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default Working with code behind - How To

I am a .net beginner. I want to know how do i write this asp code using code behind

<html>
<form method=post, action=login.asp...>
        <% if request.form("act") = "" then %>
            <type=textbox.......>
            ....Html Code To Create Form Controls...
            <type=submit, name=act, value=submit>
    </form>
        <% elseif LogInSuccess then
             response.write "Login Success"
         else
             response.write "Login Failed"
         end if
        %>
</html>

LoginSuccess is a boolean function that return true if login is successfull else it return false

the sysntex may not be exactly correct. please ignor that. Just tell me how to write this code using code behind. Please.

punkaj
__________________
punkaj
 
Old February 26th, 2005, 06:08 PM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 336
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alyeng2000
Default

Click On Any Aspx Page Or add new web page .aspx and add this code after change Design View to HTML view

Ahmed Ali
Software Developer
 
Old February 28th, 2005, 06:40 AM
Authorized User
 
Join Date: Feb 2005
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Well, thanks. but i've written that code in .aspx file in html view itself. It is running. But my question actualy was Can i write it using CODE BEHIND ie in .vb or .cs file????? instead of mixing scripting code such as...

       <% if request.form("act") = "" then %>

     in html code?????

please guide me

punkaj
 
Old February 28th, 2005, 10:34 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
Default

What kind of authentication are you using?

 
Old March 1st, 2005, 07:10 AM
Authorized User
 
Join Date: Feb 2005
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It's just a simple login application will just ask for a user id and passsword and will confirm that that the user is valid to enter in the application by fatching values from the db.

but i don't think this has something to do with my problem.

punkaj
 
Old March 4th, 2005, 11:54 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 336
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alyeng2000
Default

why you don't try to write code in vb file prefeared and easiest

Ahmed Ali
Software Developer
 
Old March 10th, 2005, 07:49 AM
Authorized User
 
Join Date: Feb 2005
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

That is i want. i've written this code using html in asp.net
now i want to make the script saperate from the html code in a vb file.

Quote:
quote:Originally posted by alyeng2000
 why you don't try to write code in vb file prefeared and easiest

Ahmed Ali
Software Developer
punkaj
 
Old March 11th, 2005, 01:13 AM
Registered User
 
Join Date: Feb 2005
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi punkaj,

 You simply assign onclick property to submit button like..
(Login.aspx)
<html>
   <form method=post, action=login.asp...>
            <type=textbox.......>
            ....Html Code To Create Form Controls...
            <type=submit, name=act, value=submit onclick=Submit_Click()>
    </form>
</html>

(Login.aspx)Code Behind File

Public Sub Submit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Submit.Click

   ....You cross check with database for login password values...if its true make LogInSuccess=TRUE...

     if LogInSuccess then
           response.write "Login Success"
      else
           response.write "Login Failed"
      end if
End Sub

cheers
srinu






Similar Threads
Thread Thread Starter Forum Replies Last Post
Working Code - Ch15 slurp56 BOOK: Professional PHP 5 ISBN: 978-0-7645-7282-1 3 April 24th, 2013 10:32 AM
Code not working billytikky88 C# 1 February 17th, 2008 03:20 PM
Code not working well vinish Beginning PHP 2 November 11th, 2005 08:02 PM
Select From Where Code not working...help bidatad Access VBA 2 April 1st, 2005 03:25 PM
code not working Toka1 Javascript How-To 12 December 17th, 2003 05:08 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.