|
When you submit the form, it will be posted to the URL in the action argument in the form tag. As that URL doesn't have any querystring, the Request.QueryString collection will be empty, and the loop will run zero times. You have to add a value to the querystring of the URL, so that you can access it when the form is posted back to the page.
Looping throught the Request.QueryString collection is a bad way of handling querystring values. Just use the name of the value to read it:
vtopid = request.QueryString("SomeNameInTheQueryString")
The form tag goes inside the body tag, and you need a </form> tag to mark the end of the form.
Experience is the sum of all the mistakes you have done.
|
|
|
|
|
I have added the script below to my website and if it is in test mode, it works fine - it writes the data to the screen. But when I take it out of test mode, it doesn't email me the data. I have pasted the script along with my code for the form. Can someone please tell me why it's not emailing? (Also, fyi, I do have a .txt file setup for the formatting of the email.) Thank you!
ASP Script named sendmail_cdo.asp
<%
option explicit
'---------------------------------------------------------------------------------------------------
'FORM MAIL SCRIPT
'----------------
'usage:
'<form ACTION="sendmail.asp" ...>
'
'hidden fields:
' redirect - the url to redirect to when the mail has been sent (REQUIRED)
' mailto - the email address of the recipient (separate multiple recipients with commas) (REQUIRED)
' cc - the email address of the cc recipient (separate multiple recipients with commas) (OPTIONAL)
' bcc - the email address of the bcc recipient (separate multiple recipients with commas) (OPTIONAL)
' mailfrom - the email address of the sender (REQUIRED)
' subject - the subject line of the email (REQUIRED)
' message - the message to include in the email above the field values. not used when a template is being used. (OPTIONAL)
' template - specifies a text or html file to use as the email template, relative to the location of the sendmail script. (e.g. ../email.txt)
' A template should reference form fields like this: [$Field Name$]
' html - if this has the value "yes", the email will be sent as an html email. only used if a template is supplied.
' testmode - if this is set to "yes", the email contents will be written to the screen instead of being emailed.
'---------------------------------------------------------------------------------------------------
dim pde : set pde = createobject("scripting.dictionary")
'---------------------------------------------------------------------------------------------------
'PREDEFINED ADDRESSES for the "mailto" hidden field
'if you don't want to reveal email addresses in hidden fields, use a token word instead and specify
'below which email address it applies to. e.g. <input type="hidden" name="mailto" value="%stratdepartment%">
'ALSO, in the same way, you can use %mailfrom% to hide the originating email address
pde.add "%contactform%", "myemail@someaddress.com"
pde.add "%salesenquiry%", "anotheremail@someaddress.com"
'---------------------------------------------------------------------------------------------------
function getTextFromFile(path)
dim fso, f, txt
set fso = createobject("Scripting.FileSystemObject")
if not fso.fileexists(path) then
getTextFromFile = ""
exit function
end if
set f = fso.opentextfile(path,1)
if f.atendofstream then txt = "" else txt = f.readall
f.close
set f = nothing
set fso = nothing
getTextFromFile = txt
end function
dim redir, mailto, mailfrom, subject, item, body, cc, bcc, message, html, template, usetemplate, testmode
redir = request.form("redirect")
mailto = request.form("mailto")
if pde.exists(mailto) then mailto = pde(mailto)
cc = request.form("cc")
bcc = request.form("bcc")
mailfrom = request.form("mailfrom")
if mailfrom = "" then mailfrom = pde("%mailfrom%")
subject = request.form("subject")
message = request.form("message")
template = request.form("template")
testmode = lcase(request.form("testmode"))="yes"
if len(template) > 0 then template = getTextFromFile(server.mappath(template))
if len(template) > 0 then usetemplate = true else usetemplate = false
dim msg : set msg = server.createobject("CDO.Message")
msg.subject = subject
msg.to = mailto
msg.from = mailfrom
if len(cc) > 0 then msg.cc = cc
if len(bcc) > 0 then msg.bcc = bcc
if not usetemplate then
body = body & message & vbcrlf & vbcrlf
else
body = template
end if
for each item in request.form
select case item
case "redirect", "mailto", "cc", "bcc", "subject", "message", "template", "html", "testmode"
case else
if not usetemplate then
if item <> "mailfrom" then body = body & item & ": " & request.form(item) & vbcrlf & vbcrlf
else
body = replace(body, "[$" & item & "$]", replace(request.form(item),vbcrlf,"<br>"))
end if
end select
next
if usetemplate then 'remove any leftover placeholders
dim rx : set rx = new regexp
rx.pattern = "\[\$.*\$\]"
rx.global = true
body = rx.replace(body, "")
end if
if usetemplate and lcase(request.form("html")) = "yes" then
msg.htmlbody = body
else
msg.textbody = body
end if
if testmode then
if lcase(request.form("html")) = "yes" then
response.write "<pre>" & vbcrlf
response.write "Mail to:" & mailto & vbcrlf
response.write "Mail from:" & mailfrom & vbcrlf
if len(cc) > 0 then response.write "Cc:" & cc & vbcrlf
if len(bcc) > 0 then response.write "Bcc:" & bcc & vbcrlf
response.write "Subject:" & subject & vbcrlf & string(80,"-") & "</pre>"
response.write body
else
response.write "<html><head><title>Sendmail.asp Test Mode</title></head><body><pre>" & vbcrlf
response.write "Mail to: " & mailto & vbcrlf
response.write "Mail from: " & mailfrom & vbcrlf
if len(cc) > 0 then response.write "Cc: " & cc & vbcrlf
if len(bcc) > 0 then response.write "Bcc: " & bcc & vbcrlf
response.write "Subject: " & subject & vbcrlf & vbcrlf
response.write string(80,"-") & vbcrlf & vbcrlf & "<span style=""color:blue;"">"
response.write body & "</span>" & vbcrlf & vbcrlf
response.write string(80,"-") & vbcrlf & "**END OF EMAIL**</pre></body></html>"
end if
else
msg.send
response.redirect redir
end if
set msg = nothing
%>
Form page...
<form name="form1" method="post" action="sendmail_cdo.asp">
<div align="left">
<p class="style3">
<input name="redirect" type="hidden" id="redirect" value="surveycomplete.htm">
<input name="mailto" type="hidden" id="mailto" value="melissawaldrop@comcast.net" />
<input name="subject" type="hidden" id="subject" value="New Inquiry">
<input name="template" type="hidden" id="template" value="contactform.txt">
<input name="testmode" type="hidden" id="testmode" value="no">
</p>
<p class="style3">First Name
<input name="FName" type="text" id="FName">
Last Name
<input name="LName" type="text" id="LName">
</p>
<p class="style20"><span class="style3"><span class="style31">Email</span>
<input name="Email" type="text" id="Email">
<span class="style31">Phone </span>
<input name="Phone" type="text" id="Phone">
</span> </p>
<p>
<input type="submit" name="Submit" value="Send">
</p>
</div>
</form>
|
|
|
|
|
hi:
now,i want use javascript to break a table into two tables like below:
<table id="t1">
<tr>
<td></td>
</tr>
<tr>
<td></td>
</tr>
</table>
now,i mean that,i want add html code of "</table><table>" in "</tr><tr>",change the table of "t1" into two tables.
how can i do with javascript?
thx
One is never too old to learn
|
|
|
|
|
You can't. You have to add another table to the page and move the rows into it.
What is it that you are trying to accomplish, really?
Experience is the sum of all the mistakes you have done.
|
|
|
|
|
Hi,Guffa,thanks for your answer.maybe i know how to do it.;)
One is never too old to learn
|
|
|
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Untitled Page</title>
<script type="text/javascript">
function createTable(rows,cols){
var table = document.createElement("TABLE");
var newAttr = document.createAttribute("border");
newAttr.nodeValue = "1px"
table.setAttributeNode(newAttr);
for(var i=0;i<rows;i++){
var row = document.createElement("TR");
for(var j=0;j<cols;j++){
var cell = document.createElement("TD");
cell.innerHTML = "Row : " + i + "Col : " + j;
row.appendChild(cell);
}
table.appendChild(row);
}
showThisInBody(table);
}
function showThisInBody(obj){
document.body.appendChild(obj);
}
</script>
</head>
<body>
<input type="button" onclick="createTable(10,2);" value="createTable(10,2)">
</form>
</body>
</html>
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
Please vote the message if it's useful.. Thanks.
|
|
|
|
|
Hello,
im trying to register a new website under IIS,but when i create DirectoryEntry object like this:
string IISPath = "IIS://" + ConfigurationManager.AppSettings["ServerName"].ToString() + "/W3SVC/1/Root";
DirectoryEntry oDE = new DirectoryEntry(IISPath);
and then try to check if it was created:
DirectoryEntry.Exists(IISPath);
application throws an exception:
Unknown error (0x80005000)
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Runtime.InteropServices.COMException: Unknown error (0x80005000)
i thought this:
http://msdn2.microsoft.com/en-us/library/ms180891(vs.80).aspx would help,but i could do nothing with that primary token maybe i understood it not properly
Can anyone help,plz?
thenk You for attention
|
|
|
|
|
|
thnx,but the code i have is almost the same...but it still throws the exception
|
|
|
|
|
|
thanx,does that mean that smth is wrong with windows on server,not with code?..But i've got win 2003 server there,not 2000..:(So,still have no solution
|
|
|
|
|
Is anyone familiar with seam cropping?
How new is this?
|
|
|
|
|
You mean that seam-carving demo a few months back? Pulling out a minimum-entropy line from an image? AFAIK its within 3 months old. Probably patented up the wazoo too
|
|
|
|
|
Yep thats the one...
And patents for sure. Do you think its possible to seam carve a website to make it smaller but still active and usable??
|
|
|
|
|
Hrmmm. Typically websites are already quite structured. The information isnt usually that "spatial" compared to a photo.
I don't think that seam carving would be the technique to reduce a page's physical size.
If this is your website you could try messing around with an "importance" factor for each piece of content - and then use some kind of dynamic layout algorithm. Laying out content based on importance using a squarified treemap algorithm may have interesting results. Then you can set a minimum importance threshold to reduce the data needed.
|
|
|
|
|
Hi,
I have a demo site up and would like to be certain that if I have the following in my page that it will definately show not show up in a search engne:
What else do I need to add to be 110% sure?
Regards
|
|
|
|
|
I think you can specify the blocked page in robots.txt..
|
|
|
|
|
Create a robots.txt file in your root directory then just write these line in it:
User-agent: *
Disallow: /
This will prevent search engines like Google, Yahoo, Msn and all those who respect Robots.txt Protocol crawling your web site.
Hope it helps !
AliAmjad(MCP)
First make it Run THEN make it Run Fast!
|
|
|
|
|
So what about search engines that do not respect robots. Would it help him to put the website in a password protected area? Or is that too much?
|
|
|
|
|
It's just a protocol and it entirely depends on the Bot whether it supports it or not and those who doesn't support it called Bad Bots. But to really protect your files from Bad bots you can setup Spider traps etc.
AliAmjad(MCP)
First make it Run THEN make it Run Fast!
|
|
|
|
|
Hey,
I'm pretty new in programming ASP.NET and C# in general so my question might be pretty easy for some of you.
I created an ASP.NET Webform. On the server, that will host the page there's another Windowsapplication running. I need to use some data of the Windowsapplication in my ASP.NET page. How do I get access to the data of the Windowsapplication? Is there any possibility that my Webform can communicate with the Windowsapplication? The webform and the winform are both written in C#.
Thanks in advance
|
|
|
|
|
Ideally you would factor the business logic of the windows app into a dll which your web app could also call.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi all,
I have to change the grid row color dynamically by using java script. I am using Infragistics grid.
activeGridRow = igtbl_getActiveRow("UltraWebGrid1");
I got the active grid row by using the above code.
But I dont know how to change the color dyanamically.
I have tried in so many ways such as
activeGridRow.element.sytle.color="red";
activeGridRow.element.style.backgroudcolor="red";
activeGridRow.element.currentStyle.color="red"
activeGridRow.element.currentStyle.backgroudcolor="red";
activeGridRow.element.runtimeStyle.color="red"
activeGridRow.element.runtimeStyle.backgroundcolor="red"
The above code that not in the exact syntax.
None of the above are changing the color of the active selected row.
So can you please give me the solution.
Thanks in advance.
Good Is Not Good When Better Is Expected.
|
|
|
|
|
A AntonySP wrote: activeGridRow = igtbl_getActiveRow("UltraWebGrid1");
What is the return type of igtbl_getActiveRow() function? TR?
what about them??
activeGridRow.style.bgcolor="red";
OR
activeGridRow.style.backgroundColor="red";
Note: "C" should be capital letter.
OR
activeGridRow.element.style.bgcolor="red";
OR
activeGridRow.element.style.backgroundColor="red";
|
|
|
|
|
Hi,
The above four possibilities not working.
The return type of igtbl_getActiveRow() is gridRow.
Good Is Not Good When Better Is Expected.
|
|
|
|