Showing posts with label filled. Show all posts
Showing posts with label filled. Show all posts

Monday, March 26, 2012

Html form trouble

Hi,
On my asp.net page I have an html form. I've set runat attribute to server
and filled it with server controls. All settings
are as I like them.
So here's the problem: when I perform a search for the first time, everythin
g works perfectly. If I make any changes to the
controls in the form and resubmit the page, nothing changes. That is, viewi
ng the querystring, not a single value is altered
despite my doing so in the form itself.
Is there some problem with the html form? I can't for the life of me figure
this out. Any help would be greatly appreciated.
Thanks,
RoshawnHi,
Roshawn wrote:
> Hi,
> On my asp.net page I have an html form. I've set runat attribute to
> server and filled it with server controls. All settings are as I like
> them.
> So here's the problem: when I perform a search for the first time,
> everything works perfectly. If I make any changes to the controls in
> the form and resubmit the page, nothing changes. That is, viewing the
> querystring, not a single value is altered despite my doing so in the
> form itself.
> Is there some problem with the html form? I can't for the life of me
> figure this out. Any help would be greatly appreciated.
> Thanks,
> Roshawn
We'll need to see some code. Please post an extract of your code able to
reproduce the problems, stripping what is not necessary.
Greetings,
Laurent
--
Laurent Bugnion [MVP ASP.NET]
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Hi Laurent. Sorry for the delayed response, been busy. As you requested, h
ere's some code.
HTML Form
<form runat="server" enableviewstate="false">
<label for="q">Search:</label><br/>
<input type="text" name="q" id="q" maxlength="100" /><br/>
<label for="sz">Shoe Size:</label><br/>
<asp:dropdownlist id="sz" runat="server" enableviewstate="false">
<asp:listitem value="-24">Any</asp:listitem>
<asp:listitem value="42802">5 & Smaller</asp:listitem>
<asp:listitem value="37090">6</asp:listitem>
<asp:listitem value="22806">7</asp:listitem>
<asp:listitem value="1032">8</asp:listitem>
'more listitems go here
</asp:dropdownlist><br/>
<label for="tp">Type:</label><br/>
<asp:dropdownlist runat="server" id="tp" enableviewstate="false">
<asp:listitem value="-24">Any</asp:listitem>
<asp:listitem value="2293">Athletic</asp:listitem>
<asp:listitem value="31920">Athletic-Inspired</asp:listitem>
</asp:dropdownlist><br/>
<label for="cd">Condition:</label><br/>
<asp:dropdownlist id="cd" runat="server" enableviewstate="false">
<asp:listitem value="-24">Any</asp:listitem>
<asp:listitem value="31919">New</asp:listitem>
</asp:dropdownlist><br/>
<input type="submit" id="submit" value="Search" />
</form>
Code to handle form (note that this uses the eBay XML API; it works as expec
ted and is called in the Page_Load event)
Private Sub GetShoeResults()
Dim hp As New MyHelper() 'declared variable for the MyHelper class for auxil
lary functions
Dim shoe As Shoe = New Shoe()'custom class
Dim sb As New StringBuilder("<?xml version=""1.0"" encoding=""utf-8""?>")
With sb
.Append("<GetSearchResultsRequest xmlns=""urn:ebay:apis:eBLBaseComponents"">
<RequesterCredentials><eBayAuthToken>" &
ConfigurationManager.AppSettings("Token") & "</eBayAuthToken></RequesterCred
entials>")
.Append("<CategoryID>63850</CategoryID><DetailLevel>ReturnAll</DetailLevel>"
)
If Request.QueryString("q") <> "" Then
.Append("<Query>" & Request.QueryString("q") & "</Query>")
End If
.Append("<SearchRequest><AttributeSetID>22</AttributeSetID><ProductFinderID>
22</ProductFinderID>")
'for the Size Parameter
If Request.QueryString("sz") <> "" Then
'turn off all selected items
For i = 0 To Me.sz.Items.Count - 1
Me.sz.Items(i).Selected = False
Next
.Append("<SearchAttributes><AttributeID>53</AttributeID><ValueList><ValueID>
" & Request.QueryString("sz") &
"</ValueID></ValueList></SearchAttributes>")
Dim item As ListItem
For Each item In Me.sz.Items
If item.Value = Request.QueryString("sz") Then
shoe.Size_ID = item.Value
shoe.Size = item.Text
item.Selected = True
Exit For
End If
Next
End If
'for the Type Parameter
If Request.QueryString("tp") <> "" Then
'turn off all selected items
For i = 0 To Me.tp.Items.Count - 1
Me.tp.Items(i).Selected = False
Next
.Append("<SearchAttributes><AttributeID>54</AttributeID><ValueList><ValueID>
" & Request.QueryString("tp") &
"</ValueID></ValueList></SearchAttributes>")
Dim item As ListItem
For Each item In Me.tp.Items
If item.Value = Request.QueryString("tp") Then
shoe.Type_ID = item.Value
shoe.Type = item.Text
item.Selected = True
Exit For
End If
Next
End If
'for the Condition Parameter
If Request.QueryString("cd") <> "" Then
'turn off all selected items
For i = 0 To Me.cd.Items.Count - 1
Me.cd.Items(i).Selected = False
Next
.Append("<SearchAttributes><AttributeID>94</AttributeID><ValueList><ValueID>
" & Request.QueryString("cd") &
"</ValueID></ValueList></SearchAttributes>")
Dim item2 As ListItem
For Each item2 In Me.cd.Items
If item2.Value = Request.QueryString("cd") Then
shoe.Condition_ID = item2.Value
shoe.Condition = item2.Text
item2.Selected = True
Exit For
End If
Next
End If
'Add Pagination in case a page number is returned in the querystring
.Append("<Pagination><EntriesPerPage>10</EntriesPerPage></Pagination></GetSe
archResultsRequest>")
End With
Try
Me.Xml1.DocumentContent = hp.CreateHeaders(sb.ToString())'call to eBay
Dim ext As New XsltArgumentList()
ext.AddExtensionObject("urn:Shoes", shoe)
Me.Xml1.TransformArgumentList = ext
Me.Xml1.TransformSource = "search.xslt"
Catch ex As WebException
'handle errors here
End Try
End Sub
I hope this helps you help me. Thanks for being interested. :-)
Roshawn

Html form trouble

Hi,

On my asp.net page I have an html form. I've set runat attribute to server and filled it with server controls. All settings
are as I like them.

So here's the problem: when I perform a search for the first time, everything works perfectly. If I make any changes to the
controls in the form and resubmit the page, nothing changes. That is, viewing the querystring, not a single value is altered
despite my doing so in the form itself.

Is there some problem with the html form? I can't for the life of me figure this out. Any help would be greatly appreciated.

Thanks,
RoshawnHi,

Roshawn wrote:

Quote:

Originally Posted by

Hi,
>
On my asp.net page I have an html form. I've set runat attribute to
server and filled it with server controls. All settings are as I like
them.
>
So here's the problem: when I perform a search for the first time,
everything works perfectly. If I make any changes to the controls in
the form and resubmit the page, nothing changes. That is, viewing the
querystring, not a single value is altered despite my doing so in the
form itself.
>
Is there some problem with the html form? I can't for the life of me
figure this out. Any help would be greatly appreciated.
>
Thanks,
Roshawn


We'll need to see some code. Please post an extract of your code able to
reproduce the problems, stripping what is not necessary.

Greetings,
Laurent
--
Laurent Bugnion [MVP ASP.NET]
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Hi Laurent. Sorry for the delayed response, been busy. As you requested, here's some code.

HTML Form
<form runat="server" enableviewstate="false">
<label for="q">Search:</label><br/>
<input type="text" name="q" id="q" maxlength="100" /><br/>
<label for="sz">Shoe Size:</label><br/>
<asp:dropdownlist id="sz" runat="server" enableviewstate="false">
<asp:listitem value="-24">Any</asp:listitem>
<asp:listitem value="42802">5 & Smaller</asp:listitem>
<asp:listitem value="37090">6</asp:listitem>
<asp:listitem value="22806">7</asp:listitem>
<asp:listitem value="1032">8</asp:listitem>
'more listitems go here
</asp:dropdownlist><br/>
<label for="tp">Type:</label><br/>
<asp:dropdownlist runat="server" id="tp" enableviewstate="false">
<asp:listitem value="-24">Any</asp:listitem>
<asp:listitem value="2293">Athletic</asp:listitem>
<asp:listitem value="31920">Athletic-Inspired</asp:listitem>
</asp:dropdownlist><br/>
<label for="cd">Condition:</label><br/>
<asp:dropdownlist id="cd" runat="server" enableviewstate="false">
<asp:listitem value="-24">Any</asp:listitem>
<asp:listitem value="31919">New</asp:listitem>
</asp:dropdownlist><br/>
<input type="submit" id="submit" value="Search" />
</form>

Code to handle form (note that this uses the eBay XML API; it works as expected and is called in the Page_Load event)
Private Sub GetShoeResults()
Dim hp As New MyHelper() 'declared variable for the MyHelper class for auxillary functions
Dim shoe As Shoe = New Shoe()'custom class
Dim sb As New StringBuilder("<?xml version=""1.0"" encoding=""utf-8""?>")
With sb
.Append("<GetSearchResultsRequest xmlns=""urn:ebay:apis:eBLBaseComponents""><RequesterCredentials><eBayAuthToken>" &
ConfigurationManager.AppSettings("Token") & "</eBayAuthToken></RequesterCredentials>")
.Append("<CategoryID>63850</CategoryID><DetailLevel>ReturnAll</DetailLevel>")
If Request.QueryString("q") <"" Then
.Append("<Query>" & Request.QueryString("q") & "</Query>")
End If
.Append("<SearchRequest><AttributeSetID>22</AttributeSetID><ProductFinderID>22</ProductFinderID>")
'for the Size Parameter
If Request.QueryString("sz") <"" Then
'turn off all selected items
For i = 0 To Me.sz.Items.Count - 1
Me.sz.Items(i).Selected = False
Next
.Append("<SearchAttributes><AttributeID>53</AttributeID><ValueList><ValueID>" & Request.QueryString("sz") &
"</ValueID></ValueList></SearchAttributes>")
Dim item As ListItem
For Each item In Me.sz.Items
If item.Value = Request.QueryString("sz") Then
shoe.Size_ID = item.Value
shoe.Size = item.Text
item.Selected = True
Exit For
End If
Next
End If
'for the Type Parameter
If Request.QueryString("tp") <"" Then
'turn off all selected items
For i = 0 To Me.tp.Items.Count - 1
Me.tp.Items(i).Selected = False
Next
.Append("<SearchAttributes><AttributeID>54</AttributeID><ValueList><ValueID>" & Request.QueryString("tp") &
"</ValueID></ValueList></SearchAttributes>")
Dim item As ListItem
For Each item In Me.tp.Items
If item.Value = Request.QueryString("tp") Then
shoe.Type_ID = item.Value
shoe.Type = item.Text
item.Selected = True
Exit For
End If
Next
End If
'for the Condition Parameter
If Request.QueryString("cd") <"" Then
'turn off all selected items
For i = 0 To Me.cd.Items.Count - 1
Me.cd.Items(i).Selected = False
Next
.Append("<SearchAttributes><AttributeID>94</AttributeID><ValueList><ValueID>" & Request.QueryString("cd") &
"</ValueID></ValueList></SearchAttributes>")
Dim item2 As ListItem
For Each item2 In Me.cd.Items
If item2.Value = Request.QueryString("cd") Then
shoe.Condition_ID = item2.Value
shoe.Condition = item2.Text
item2.Selected = True
Exit For
End If
Next
End If
'Add Pagination in case a page number is returned in the querystring
.Append("<Pagination><EntriesPerPage>10</EntriesPerPage></Pagination></GetSearchResultsRequest>")
End With
Try
Me.Xml1.DocumentContent = hp.CreateHeaders(sb.ToString())'call to eBay
Dim ext As New XsltArgumentList()
ext.AddExtensionObject("urn:Shoes", shoe)
Me.Xml1.TransformArgumentList = ext
Me.Xml1.TransformSource = "search.xslt"
Catch ex As WebException
'handle errors here
End Try
End Sub

I hope this helps you help me. Thanks for being interested. :-)

Roshawn

Saturday, March 24, 2012

HTML Email Help

I am trying to send an email automatically when a user has filled in a web form.

I have been using the contents of each textbox so that the email can display details of a specific order. For example, txtForename.text, which could contain "Jerry".

I have been trying many different ways to rectify the error, with now luck.

My code looks like this:

' Send Email to customer
Dim Mail As New MailMessage()
Mail.To = lblEmail.text
Mail.From = "rentals@dotnet.itags.org.OCR.com"
Mail.Subject = "Rental Details"
Mail.BodyFormat = MailFormat.Html
Mail.Body = "<h1>Rental Summary</h1><hr /><table width='100%'><tr><td colspan='2'><h2><u>Personal Details</u></h2></td></tr><tr><td></td><td></td></tr>" & _
"<tr><td width='9%'><b>Name:</b></td><td width='91%'>" & lblForename.text & lblSurname.text & "</td></tr><tr><td></td><td></td></tr><tr><td><b>Address:</b></td><td>"& lblAddress1.text &"</td>" & _
"</tr><tr><td></td><td>"& lblAddress2.text & "</td></tr><tr><td></td><td>" & lblCounty.text & "</td></tr><tr><td></td><td></td></tr><tr><td><b>Post Code:</b> </td><td>" & lblPostcode.text & "</td>" & _
"</tr><tr><td></td><td></td></tr><tr><td><b>Tel No:</b></td><td>" & lblTelNo.text & "</td></tr><tr><td></td><td></td></tr><tr><td><b>Email Address:</b> </td>" & _
"<td>" & lblEmail.text & "</td></tr><tr><td></td><td></td></tr></table><br /><table width='100%'><tr><td colspan='2'><h2><u>Purchase Information</u></h2></td>" & _
"</tr><tr><td width='10%'></td><td width='90%'></td></tr><tr><td><b>Car:</b></td><td>" & lblCarModel.text & "</td></tr><tr><td></td><td></td></tr><tr><td><b>Price:</b></td>" & _
"<td>" & lblCarPrice.text & "</td></tr><tr><td></td><td></td></tr><tr><td></td><td></td></tr><tr><td><b>Accessory Name:</b></td><td>" & lblAccessoryName.text & "</td></tr><tr><td><b>Price:</b></td>" & _
"<td>" & lblAccessoryPrice.text & "</td></tr><tr><td></td><td></td></tr><tr><td><b>Pickup Date:</b></td><td>" & lblCollectDate.text & "</td></tr><tr><td></td><td></td></tr><tr><td><b>Return Date:</b></td>" & _
"<td>" & lblReturnDate.text & "</td></tr></table><br />"
SmtpMail.SmtpServer = "localhost"
SmtpMail.Send(Mail)

I have created the email in a table format as you can see. I don't think there is any errors in the email structure. However, I am getting the following error:

Server Error in '/' Application.

The server rejected one or more recipient addresses. The server response was: 550 5.7.1 Unable to relay for someone@dotnet.itags.org.hotmail.com

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: The server rejected one or more recipient addresses. The server response was: 550 5.7.1 Unable to relay for someone@dotnet.itags.org.hotmail.com

Source Error:

Line 153: "<td>" & lblReturnDate.text & "</td></tr></table><br />"
Line 154: SmtpMail.SmtpServer = "localhost"
Line 155: SmtpMail.Send(Mail)
Line 156:
Line 157: Response.Redirect("RecordProcess.aspx")


I would appreciate any help anyone could give me!

You need to pass username/pass to your SMTP or adjust the SMTP to allow your access.

There was a post yesterday with the exact syntax for passing the credentials, but basically that's all it is.


Thats great thanks for your help!

I will try it out!