can i have only one form per ASP.Net page?
No,You can have multiple forms, but only one form can be set with the runat=”server” attribute.
can i have only one form per ASP.Net page?
No,You can have multiple forms, but only one form can be set with the runat=”server” attribute.
How can I access web controls from a code-behind page?
In the general declaration for your code behind class, create a control variable with the same name as the id of the control in your .aspx file:
Public Class CodeBehind : Inherits Page
Public ItemsGrid As DataGrid
Protected Sub Page_Load(ByVal Sender As System.Object, ByVal e As System.EventArgs)
If Not IsPostback Then
ItemsGrid.DataSource = GetMyDataSource()
ItemsGrid.DataBind()
End If
End Sub
End Class
How do you prevent a user who doesnt log off a site from backing into a site if they leave it. Say for example a person logs into http://www.cpwebhosting.net but they dont log off, they instead type other domain name into the browser. Once they are on other domain name they decide to hit the back button to get back to cpwebhosting.net, the actually logged in account. How do i prevent them from doing so, and if they try to back into the site it tells them to log on again? Is this possible? I need help, new to ASP.
Try this one
Code:
<%
Dim objConn
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.open dsn
If Session("blnValidUser") = True and Session("Admin_ID") = "" Then
Dim rsPersonIDCheck
Set rsPersonIDCheck = Server.CreateObject("ADODB.Recordset")
Dim strSQL
strSQL = "SELECT * FROM Settings WHERE Admin_ID = '" & Session("Admin_ID") & "';"
rsPersonIDCheck.Open strSQL, objConn
If rsPersonIDCheck.EOF Then
Session("blnValidUser") = False
Else
Session("Admin_ID") = rsPersonIDCheck("Admin_ID")
End If
rsPersonIDCheck.Close
Set rsPersonIDCheck = Nothing
End If
Dim strID, strPassword
strID = Request("Admin_ID")
strPassword = Request("Password")
Dim rsUsers
set rsUsers = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT * FROM Settings WHERE Admin_ID = '" & strID & "';"
rsUsers.Open strSQL, objConn
If rsUsers.EOF Then
Session("Admin_ID") = Request("Admin_ID")
Response.Redirect "default.asp?SecondTry=True"
Else
While Not rsUsers.EOF
If UCase(rsUsers("Admin_Pass")) = UCase(strPassword) Then
Session("Admin_ID") = rsUsers("Admin_ID")
Session("isLoggedIn") = True
Session("blnValidUser") = True
Response.Redirect "main.asp"
Else
rsUsers.MoveNext
End If
Wend
Session("Admin_ID") = Request("Admin_ID")
Response.Redirect "default.asp?SecondTry=True&WrongPW=True"
End If
%>
you'll need to tell us how you keep the session for logged in users, is it just a session or a cookie???
No, it is not a cookie, just a session
chack the referer, if its not your site then Session("Admin_ID") = ""
put the site in a frameset and then have an onUnload procedure on the frameset to destroy the session.
Put this code
Code:
strURLIn = Request.ServerVariables("HTTP_REFERER")
if strURLIn <> "" AND left(strURLIn, 23)<>"http://www.cpwebhosting.net" AND left(strURLIn, 19)<>"http:/cpwebhosting.net" then
Session("Admin_ID") = ""
I have a spammer attacking my ASP contact forms on my website. They’re just a really basic ASP form using CDO. My host suggested that I redesign the forms to not allow more than a specified number of submissions per IP address. Does anyone know how to do that?
use an image captcha into your form. google “captcha”
captcha is only effective if you’ve got spammers that are spamming your site programmatically, however. If you’ve got spammers that are going in and manually submitting your forms.
You should also check and see if the CAPTCHA has a counter to block x number of wrong submitted CAPTCHA inputs. And have a redirect to set to take them to a diffrent page when it is reached.
Hi,
I am reading data from XL and displaying on a web page and as the data is more i have to scroll the data upwards.
But how do I see column names always?
As the datascrolls up, by column names are also gone up but I need to keep them and scroll only other rows.
Please help me.
have an absolutely positioned (css) div with the column names always placed at a TOP and LEFT position.
have something like frames, or JavaScript working there
I am looking for some .asp code to use where other webmasters can submit links for approval (moderated), and perhaps some code that checks reciprocal links, and if legit, then will allow thier link on your page?
You earn to use XMLHTTP and of regexp to check link in other page
How to reach a specific folder in my webuser’s computer.I want when a user click a link, my asp page have to go a spesific folder
is there any ocx or dll to reach webuser’s computer?
ocx came from Microsoft on MSN Space. when user accept activex, it reads our harddisk to add pitcures. There must have been an ocx. I have to find or I will die
no, u can not do it
You can make an ocx yourself, but it works on IE only.
with the using of FSO (File System Object), u can read a file
Code:
<%
Set fs=Server.CreateObject("Scripting.FileSystemObject")
Set f=fs.OpenTextFile("C:/Documents and Settings/username/blabla.txt", 1)
Response.Write(f.ReadAll)
f.Close
Set f=Nothing
Set fs=Nothing
%>
Browsers don't allow this due to user's security settings. Firefox and opera strictly forbid this, while IE uses security zone to enforce the permissions given to web page.
Code:
<%
Set fs=Server.CreateObject("Scripting.FileSystemObject")
Set f=fs.OpenTextFile("C:/Documents and Settings/username/blabla.txt", 1)
Response.Write(f.ReadAll)
f.Close
Set f=Nothing
Set fs=Nothing
%>
thats for the server that hosts your site or for client side
that's for server side.
Hi,
Is there a way to convert ASP page to PDF. I want to convert my ASP page to PDF when I give print this page option.
thanks
pdf995 is a free prog that works as a virtual pdf printer
There is one way to convert any file (text or doc or htm or anyother) is to install a virtual printer and select it as a printer while printing, u will be able to save it as PDF file..
Try Persits Software Inc., which has a component related about online converting to PDF
Yes, u r right tertius. I have used a few of the Persits Software Inc components.
hello,
just a newbie in web development, also in ASP and PHP.
i just wanna ask how to send the data gathered from forms to emails?
Plz. help
Here is a php script that will send any form information to an e-mail address
Code:
if ($_SERVER['REQUEST_METHOD'] != "POST"){exit;}
$message = "";
while(list($key,$value) = each($_POST)){if(!(empty($value))){$set=1;}$message = $message . "$key: $valuenn";} if($set!==1){header("location: $_SERVER[HTTP_REFERER]");exit;}
$message = stripslashes($message);
$to = "yourmail@yourdomain.com";
$subject = "Your Subject";
if (mail($to, $subject, $message))
{
echo("<h1>Thank You</h1>");
}
web host support different types of DLLs that are used for send email.
Yes steve
Windows NT - 2000 support CDONTS by default, Windows 2000 and 2003 support CDOSYS by default. Many providers support CDONTS on 2003 as well as other objects such as ASPEmail, Jmail and others.Code:
Code:
if ($_SERVER['REQUEST_METHOD'] != "POST"){exit;}
$message = "";
while(list($key,$value) = each($_POST)){if(!(empty($value))){$set=1;}$message = $message . "$key: $valuenn";} if($set!==1){header("location: $_SERVER[HTTP_REFERER]");exit;}
$message = stripslashes($message);
$to = "yourmail@yourdomain.com";
$subject = "Your Subject";
if (mail($to, $subject, $message))
{
echo("<h1>Thank You</h1>");
Thanks stevon but have another question...
How do we email multiple fields using PHP?
For example, in here mail($to, $subject, $message), you are only allowed one variable: $message. What if your form contains, say, 4 variables that need to be emailed.
Try this code, I Hope it will help You.
Code:
$message = "The following data subimitted: n
variable1: ".$var1."n
"variable2: ".$var2."n
"variable3: ".$var3."n
"variable4: ".$var4."nn Thank You";
$to = "yourmail@yourdomain.com";
$subject = "Your Subject";
if (mail($to, $subject, $message))
{
echo("<h1>Thank You</h1>");
}
I have been using the post method, but that only works for one other page…how do I go about making variables available to more than one page?
U can not do it in ASP.NET but If you’re using ASP 3.0 there is way to do this is to use session variables, which is not too effective in my opinion.
for session variables – use the request.form method like this:
session(“your_session_variable”) = request.form(“your_form_variable”)
then whenever you want to reference that session variable throughout the remainder of the session, just call it like any other… for example
response.write session(“your_session_variable”)
You must be logged in to post a comment.