Skrive en Slet-knap afhængig af bruger...
Hvordan for jeg slette knappen længere nede på siden til kun at dukke frem hvis man er administrator? Det er dette stykke kode der skal komme frem...<%
If Len(strEdit) <> 0 Then
%>
<input type="button" value="Slet" name="Slet" onClick="java script:location.href='Artikel.asp?mode=slet&id=<%=strId%>'"><br></td></tr>
<%
End If
%>
<body bgcolor="#ffffff" topmargin="5" leftmargin="0" marginwidth="0" marginheight="0">
<center>
<%
If strEdit = 1 Then
Set myConn = Server.CreateObject("ADODB.Connection")
myConn.Open tempConn
strSQL = "SELECT * FROM ForsArtikel Where Id = " & strId
Set rs = myConn.Execute(strSQL)
If Not (rs.BOF Or rs.EOF) Then
strOverskrift = rs("Overskrift")
strBillede = rs("Billede")
strTeaser = rs("Teaser")
strForfatter = rs("Navn")
strArtikel = rs("Artikel")
End If
myConn.Close
Set myConn = Nothing
strEdit = 2
strMode = "add"
End If
Select Case strMode
Case "slet"
Set myConn = Server.CreateObject("ADODB.Connection")
myConn.Open tempConn
SQL = "DELETE FROM Artikel WHERE (ID = " & strId & ") "
myConn.Execute (SQL)
myConn.Close
Set myConn = Nothing
Response.Redirect("Artikel.asp")
Case "add"
%>
<div align="center">
<table align="center" border="0" width="550" cellspacing="0" cellpadding="2" style="border-left: 1px solid rgb(0,0,0); border-right: 1px solid rgb(0,0,0); border-top: 1px solid rgb(0,0,0); border-bottom: 1px solid rgb(0,0,0)">
<form method="POST" action="Artikel.asp?id=<%=strId%>">
<tr>
<td valign="middle" align="center" colspan="2" bgcolor="E3E5EC"><b>Indtast dine data i følgende felter:</b><%=strError%></td>
</tr>
<tr>
<td width="30%" align="right" valign="middle">Artikeloverskrift:</td>
<td width="70%" valign="middle"><input type="text" name="Overskrift" size="52" value="<%=strOverskrift%>"></td>
</tr>
<tr>
<td width="30%" align="right" valign="middle">Filnavn (Billede):</td>
<td width="70%" valign="middle"><input type="text" name="Billede" size="52" value="<%=strBillede%>"></td>
</tr>
<tr>
<td width="30%" align="right" valign="middle">Teaser:</td>
<td width="70%" valign="middle"><input type="text" maxlength="60" name="Teaser" size="52" value="<%=strTeaser%>"></td>
</tr>
<tr>
<td width="30%" align="right" valign="middle">Forfatter:</td>
<td width="70%" valign="middle"><input type="text" name="Forfatter" value="<%=strForfatter%>" size="52" readonly></td>
</tr>
<tr>
<td width="30%" align="right" valign="top">Artikel:</td>
<td width="70%" valign="middle"><textarea cols="44" rows="8" name="Artikel" value=""><%=strArtikel%></textarea></td>
</tr>
<tr>
<td valign="middle" align="center" colspan="2">
<input type="submit" value="Gem" name="Gem<%=strEdit%>">
<input type="button" value="Annullér" name="Annuller" onClick="java script:location.href='Artikel.asp'">
<%
If Len(strEdit) <> 0 Then
%>
<input type="button" value="Slet" name="Slet" onClick="java script:location.href='Artikel.asp?mode=slet&id=<%=strId%>'"><br></td></tr>
<%
End If
%>
</tr>
<tr>
<td colspan="2" align="center" valign="top"><b><br><br><a href="Artikel.asp?mode=showall">Vis alle Artikler!</a> <a onMouseOver="status=' Upload et Billedee '; return true" onMouseOut="status=''; return true" onClick="openWindow('log/baser/upload.asp', WIDTH=400, HEIGHT=200); return false" href="log/baser/upload.asp">Klik her for at uploade et Billede!</a></b><br><br></td>
</tr>
</form>
</table>
hanz