Ask a Question related to ASP Database, Design and Development.
-
Shawn #1
Better way to delete - kinda long
Currently when I create add/edit/delete options for
webpages I use the following format:
3 web pages:
add - This is a regular form where you can add records
into a database. It is submitted to the manage page where
it checks for the existence of a variable (varAdd <>0),
then if it goes to that subroutine, it will insert the
record if the data is good.
edit - This is very similar to the add form except it
pulls the record from the db using a request variable
passed from the manage page. On this form is an "UPDATE"
and a "DELETE" button.
-- example of the code ---
<form action="manage.asp" name="managefrm" method="post">
<table>
<tr>
<td>Field1</td>
<td><input type="text" name="frmField1" value="<%=rs
("Field1")%>">
</td>
</tr>
<tr>
<td colspan="2" align="right">
<input name="UpdateStudent" type="hidden" value ="1" />
<input name="StudentID" type="hidden" value ="<%=StudentID%<input class="button" type="submit" value="Update Student">" />
name="butUpdate" />
<input class="button" type="submit" value="Delete Student"
name="butDelete" />
</td>
</tr>
</Table>
</form>
----- Code End ----------
Notice how I have a value in the hidden Update field and
notice the values in the buttons themselves.
manage - This section is the driver. The add and edit
call this page to process it. Now the way I currently
process an update is by checking hte existance of the
UpdateStudent hidden field, if it is <> 0 then it
processes it like an update. Here is where the problem
occurs. Since the update and delete are in the same form,
I can't pass separate variable to indicate whether an
update or a delete so what I do is this (I know its kinda
janky, but it works and that's why I'm writing):
---- Code start -----
buttonValue = request("butDelete") ' Gets the value of the
delete button if pressed
addStudent= Trim(request("addStudent"))
updateStudent= Trim(request("updateStudent"))
if buttonValue = "Delete Student" then
DeleteStudent= 3
updateStudent= ""
end if
----- Code end -------
Basically, it gets the value of the delete button if it is
pressed, because the UpdateStudent value will have a value
if pressed also, so if it has a value then it resets the
updateStudent value and processes it as a delete.
IS there a better way to tell if theuser pressed the
delete button or Update button using ASP? Thanks.
Shawn Guest
-
Can't delete folders where PATH is too long
OS: Windows XP Pro I have a client who somehow got a ba-zillion folders created and now can't delete them. I've read the Q articles Q180410 and... -
kinda OT--CDO importance
I've been using CDO to send an email with an Intranet app I have. Can't for the life of me remember where I got this code: .Importance = 1 '... -
FSO Woes(kinda long post)
Lets see if I can explain this so I can get a good answer =) I'm trying to speed up a file search via FSO. I have a database that contains the... -
what kinda mouse?
I have the ms track ball explorer 1. The ball is dragging to bad to use so I'm in the market for a new mouse...I went to the roller ball mouse cause... -
kinda OT video ?
Can a .inf file be made to run a avi or mpeg on insertion of CD? I want to put video file onto cd and have it auto start when it is inserted into...



Reply With Quote

