Having 2 SUBMIT_CLICK buttons on a page?

  • Thread starter Patrick Olurotimi Ige
  • Start date
P

Patrick Olurotimi Ige

I have a a control survey box e.g

<VTS:SURVEYBOX id="SurveyPreview" runat="server" Surveyid="1"
Width="700" BackColor="White" CellSpacing="0" CellPadding="0"
EnableValidation="true" BorderWidth="1px" BorderColor="#E0E0E0"
Font-Names="Arial" Font-Size="10pt">
</VTS:SURVEYBOX>

And it already has a submit button that users use to submit
data to the database when they finnish filling the SURVEY.
But i want to add a function that when they click on the SUBMIT button i
want to capture the LOGON_USER filling the SURVEY and add it to the
database.
Because i want to check each user after clicking the SUBMIT if they have
filled it before if they have then i want to return access denied or
survey alread filled!
Any ideas!!!
 
K

Ken Cox [Microsoft MVP]

Why not just pass a cookie when they click Submit to indicate they've done
the survey. Just check for the cookie when the page loads and disable the
Submit button if they've done it.

No pointing letting people fill out a survey if they're just going to be
told they aren't allowed to do it again.
 
P

Patrick Olurotimi Ige

Thx Ken
I was thinking of cookie and i know it could have been the best options.
But it won't work for them because u have multiple user to one PC!
By the way 'm having a problem when i'm checking the user in the DB.When
i load the page 'm always getting the ACCESS DENIED PAGE..which seems it
inserts the USER before checking.

Am i missing something??

My SProcedure and my ASP.NET below :-

CREATE procedure oyinbo(@username varchar(50) ) as
if exists
-- You cannot register usernames already registered on the database
twice.
(
select username from survey where username = @username
)
--insert survey(username,DateCreated) values(@username,getdate())
return 1 else
insert survey(username,DateCreated) values(@username,getdate())
GO


AND MY ASP.NET CODE:-
Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here

conn = New
SqlConnection("server=(local);database=Wintergreen;integrated
security=true;")
conn.Open()
txtuser.ID = Request.ServerVariables("LOGON_USER")

cmdcommand = New SqlCommand("sp_checkusers", conn)
cmdcommand.CommandType = CommandType.StoredProcedure
param = cmdcommand.Parameters.Add("ReturnValue", SqlDbType.Int)
param.Direction = ParameterDirection.ReturnValue
cmdcommand.Parameters.Add("@username", txtuser.Name)

cmdcommand.Parameters.Add(New SqlParameter("@DateCreated",
SqlDbType.DateTime, 8))
cmdcommand.Parameters("@DateCreated").Value = Now()

cmdcommand.ExecuteNonQuery()

If cmdcommand.Parameters("ReturnValue").Value = 0 Then

Response.redirect("noaccess.aspx")
' lblMessage.Text = "Username already exists!"

'Else

' lblMessage.Text = "Success!"
REsponse.Redirect("startsurvey.aspx")

End If
conn.Close()
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top