Hi all. I posted first in the general dreamweaver forum - no response. I'm new to asp.net and I have a feeling the solution for this is obvious. Please help!
So.
I have an asp.net form on one page that sends the entries to an email address. Heres the script:
<%@ Page Language="VB" EnableSessionState="False"
EnableViewState="False" Trace="False" Debug="False"%>
<%@ Import Namespace="System.Web.Mail" %>
<script language="VB" runat=server>Sub Page_Load(Sender as Object, E as EventArgs)
If Page.IsPostBack Then
lblResponse.Text = "Your email has been sent."
End If
End Sub
Sub btn_Click(sender as Object, e as System.EventArgs)
If Request.Form("Email") <> "" Then
Dim objMail As New MailMessage()
objMail.From = Request.Form("Email")
objMail.To = "jonathan.sicurella@roswellpark.org"
objMail.Subject = Request.Form("Subject")
objMail.Body = Request.Form("Message") & Request.Form("Message")
objMail.BodyFormat = MailFormat.Text
SmtpMail.SmtpServer = "smtp.roswellpark.org"
SmtpMail.Send(objMail)
Else
lblResponse.Text = "Please enter an email address."
End If
End Sub</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 4.0 Transitional//EN" >
<html xmlns="http://www.w3.org/1999/xhtml">
other stuff...
<body>
...other stuff...
<asp:Label class="main" id="lblResponse"
runat="server"/><form method="post" name="form2" runat="server">
email:<br />
<input type="text" size="44" class="main" name="Email" value=""><br />
first:<br />
<input type="text" class="main" size="20" name="First" value=""><br />
last:<br />
<input type="text" class="main" size="20" name="Last" value=""><br />
<br /><b>Dates:</b><br />
<br />
from:
<br />
<input name="text1" type="text" />
<a href="javascript:calendar_window=window.open('/asp/calendar.aspx?form name=form2 .text1','calendar_window','width=154,height=188');calendar_window.foc us()">Calen dar</a>
<br /><input type="Submit" id="btnSubmit" OnServerClick="btn_Click" value="Send" runat="server" />
</form>
... etc, etc...
</body>
</html>
The first redtextis the beginning of the form. The second redtextis the code for a textbox, with a link next to it, opening a popup window with a calendar on it. I select the date on the calendar and its SUPPOSED to close the pop up, and add the date to the textbox. Simple.
Problem is - the calendar only works when "runat='server'" is taken away from the form declaration "<form... runat="server">". The form only works (sends the email) when "runat='server'" is stated. Can't fix one without breaking the other somehow.
The second file is called "calendar.aspx." - if you need it - what the popup window actually opens and where the asp scripting for the calendar is. Script is:
<%@ Page Language="vb" %><script runat="server">
Private Sub Calendar1_SelectionChanged(sender As Object, e As EventArgs)
Dim strjscript as string = "<script language=""javascript"">"
strjscript &= "window.opener." & _
Httpcontext.Current.Request.Querystring("formname") & ".value = '" & _
Calendar1.SelectedDate & "';window.close();"
strjscript = strjscript & "</script" & ">" 'Don't Ask, Tool Bug
Literal1.Text = strjscript 'Set the literal control's text to the JScript code
End Sub
Private Sub Calendar1_DayRender(sender As Object, e As System.Web.UI.WebControls.DayRenderEventArgs)
If e.Day.Date = datetime.now().tostring("d") Then
e.Cell.BackColor = System.Drawing.Color.LightGray
End If
End Sub
</script><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html>
<head>
<title>Choose a Date</title>
</head>
<body leftmargin="0" topmargin="0">
<form runat="server">
<asp:Calendar id="Calendar1" runat="server" OnSelectionChanged="Calendar1_SelectionChanged" OnDayRender="Calendar1_dayrender" showtitle="true" DayNameFormat="FirstTwoLetters" SelectionMode="Day" BackColor="#ffffff" FirstDayOfWeek="Monday" BorderColor="#000000" ForeColor="#00000" Height="60" Width="120">
<TitleStyle backcolor="#000080" forecolor="#ffffff" />
<NextPrevStyle backcolor="#000080" forecolor="#ffffff" />
<OtherMonthDayStyle forecolor="#c0c0c0" />
</asp:Calendar>
<asp:Literal id="Literal1" runat="server"></asp:Literal>
</form>
</body>
</html>
This is probably a simple fix. Like I said I'm new to asp.net, and html-self-taught. I went through a couple tutorials, and cut and pasted some scripts I found online. I got everything to work seperately, but when I put it together, couldn't. THANKS!