• Toll-free  888-665-8637
  • International  +1 717-220-0012
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Omer
#1 Posted : Saturday, February 28, 2009 5:57:19 PM(UTC)
Omer

Rank: Member

Joined: 2/3/2007(UTC)
Posts: 100

Can someone please tell me the VB code to pull the 'wish list for a user' and write to another page? I would really appreciate it.
Omer
#2 Posted : Saturday, February 28, 2009 7:02:56 PM(UTC)
Omer

Rank: Member

Joined: 2/3/2007(UTC)
Posts: 100

I only need the image and its link. Nothing else.
Aaron
#3 Posted : Monday, March 2, 2009 2:30:21 PM(UTC)
Aaron

Rank: Administration

Joined: 4/2/2004(UTC)
Posts: 2,393
United States
Location: Hummelstown, PA

Thanks: 6 times
Was thanked: 163 time(s) in 158 post(s)
Omer,

First, go to the MyAccount_WishList.aspx page and copy the entire <asp:GridView> control and all of its contents (it starts around line 22 and goes to about line 56). Paste this code on whatever .aspx page you want to display the wish list. You may also need to copy/paste this line of code to the top of your new .aspx page:

Code:
<%@ Register Assembly="Anthem" Namespace="Anthem" TagPrefix="anthem" %>


Next, and this is a little more tricky, you will need to copy/paste a significant portion of the code-behind file (MyAccount_WishList.aspx.vb) to the code-behind file of your new page. Basically you will need to copy/past the following code elements:

1. BindItems sub
2. GridView1_RowCommand sub
3. GridView1_RowDeleting sub
4. GridView1_RowDataBound sub
5. GridView1_RowUpdating sub
6. ForceNoShoppingCartRedirection property
7. AddToCartImageButton declaration
8. AddToCartClicked event

Lastly, you will need to add this code to the Page_Load method of your new page:
Code:

If Not Page.IsPostBack Then
    BindItems()
End If
Aaron Sherrick
BV Commerce
Toll-free 888-665-8637 - Int'l +1 717-220-0012
Omer
#4 Posted : Saturday, March 14, 2009 9:22:51 AM(UTC)
Omer

Rank: Member

Joined: 2/3/2007(UTC)
Posts: 100

Aaron,
Thank you very much for your help. I am sorry I didn't see your response before. I was so busy with the new design and some site issues. I will try to do it today and see if I can get it to work. I really appreciate your help.
Omer
#5 Posted : Monday, March 16, 2009 9:15:59 AM(UTC)
Omer

Rank: Member

Joined: 2/3/2007(UTC)
Posts: 100

It seems like I couldn't do it. I was trying to create a feature for the Wish List where users can email their Wish List to someone else. I managed to have the email sent to any email address from the user account's Wish List page but can't get the Wish List in that e-mail.... LOL... I am still trying though....

I think there should be a button on the Wish List page. When a users clicks, then a separate page is created with the Wish List's images and links. (May be just the links to keep the email size small.) Then this page can be emailed. I could not get the Wish List written in the email from the main wish list page. May be it is something simple but for a beginner like me, it takes time :)
Aaron
#6 Posted : Monday, March 16, 2009 10:23:07 AM(UTC)
Aaron

Rank: Administration

Joined: 4/2/2004(UTC)
Posts: 2,393
United States
Location: Hummelstown, PA

Thanks: 6 times
Was thanked: 163 time(s) in 158 post(s)
Omer,

That would be a cool feature. A quick and dirty method is to use the rendered output of the GridView and stuff that into an email. I think that would work. The better way would be to create a new email template in the admin. However, for this to work you would need to create a [[User.WishList]] tag and the associated processing.
Aaron Sherrick
BV Commerce
Toll-free 888-665-8637 - Int'l +1 717-220-0012
Matt@9BallDesign
#7 Posted : Monday, March 16, 2009 12:01:51 PM(UTC)
Matt@9BallDesign

Rank: Member

Joined: 12/23/2003(UTC)
Posts: 909

definitely something to toss into the Feature Enhancements section. Let your users market for you!
Matt Martell


http://www.9balldesign.com - Web, Print, Graphic


http://www.martellhardware.com/ - Decorative &amp; Builder's Hardware

------------------------------------------------
Omer
#8 Posted : Monday, March 16, 2009 1:22:11 PM(UTC)
Omer

Rank: Member

Joined: 2/3/2007(UTC)
Posts: 100

I don't know what that 'rendered output of GridView'... tags and all... but looking into it :)

Yes Matt, I will post it there.
Aaron
#9 Posted : Monday, March 16, 2009 4:45:50 PM(UTC)
Aaron

Rank: Administration

Joined: 4/2/2004(UTC)
Posts: 2,393
United States
Location: Hummelstown, PA

Thanks: 6 times
Was thanked: 163 time(s) in 158 post(s)
Omer,
The code would look something like this:

Code:

Dim sw As System.IO.StringWriter = New System.IO.StringWriter()
Dim htw As HtmlTextWriter = New HtmlTextWriter(sw)
GridView1.RenderControl(htw)

' write the GridView HTML to a string
Dim wishListHtml As String = sw.ToString()


I haven't tested this, but I believe it will work.
Aaron Sherrick
BV Commerce
Toll-free 888-665-8637 - Int'l +1 717-220-0012
Andy Miller
#10 Posted : Monday, March 16, 2009 5:32:00 PM(UTC)
Andy Miller

Rank: Member

Joined: 11/5/2003(UTC)
Posts: 2,136

Was thanked: 1 time(s) in 1 post(s)
Should work great. That is basically what Anthem does for a few controls...render to a string and then replace the postback javascript with callback javascript.
Andy Miller
Structured Solutions

Shipper 3 - High Velocity Shipment Processing
Omer
#11 Posted : Tuesday, March 17, 2009 2:01:31 AM(UTC)
Omer

Rank: Member

Joined: 2/3/2007(UTC)
Posts: 100

Aaron,

I couldn't get it to work:(

I created a My_Account_WishList_Email.aspx. I only need the image and the link from the wish list. So I modified the code. I added `from` and `to` email fields and the `send` button. I used the Contact Us email template for now. Without the render code, it sends the email with Contact Us template and no content of course. When I add the code you provided, then it serves a 404. Here is my vb code:

[blue]
Imports BVSoftware.Bvc5.Core
Imports System.Collections.ObjectModel

Partial Class MyAccount_WishList_Email
Inherits BaseStorePage

Public Overrides ReadOnly Property RequiresSSL() As Boolean
Get
Return True
End Get
End Property

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Utilities.WebForms.MakePageNonCacheable(Me)

btnSend.ImageUrl = PersonalizationServices.GetThemedButton("Submit")

inMessage.Text = "<a href=""" & Request.Params("page") & """>" & Request.Params("page") & "</a>"

If Not Page.IsPostBack Then
BindItems()
End If
End Sub

Sub BindItems()
Dim w As New Collection(Of Catalog.WishList)
Dim p As New Collection(Of Catalog.Product)
w = Catalog.WishList.FindByUserBvin(SessionManager.GetCurrentUserId)
Me.GridView1.DataSource = w
Me.GridView1.DataBind()
End Sub

Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound

If e.Row.RowType = DataControlRowType.DataRow Then

Dim localWishList As Catalog.WishList = CType(e.Row.DataItem, Catalog.WishList)

Dim localP As Catalog.Product = Catalog.InternalProduct.FindByBvin(localWishList.ProductBvin)
If localP IsNot Nothing Then
Dim imgProduct As HyperLink = e.Row.FindControl("imgProduct")
Dim lnkProduct As HyperLink = e.Row.FindControl("lnkProduct")
If imgProduct IsNot Nothing Then
imgProduct.ImageUrl = Page.ResolveUrl(Utilities.ImageHelper.GetValidImage(localP.ImageFileSmall, True))
imgProduct.NavigateUrl = Utilities.UrlRewriter.BuildUrlForProduct(localP, Me.Page.Request)
End If
If lnkProduct IsNot Nothing Then
lnkProduct.Text = localP.ProductName
lnkProduct.NavigateUrl = imgProduct.NavigateUrl
End If
End If
End If
End Sub

Sub btnSend_OnClick(ByVal Sender As Object, ByVal E As ImageClickEventArgs) Handles btnSend.Click
lblErrorMessage.Visible = False
lblErrorMessage.Text = ""
lblResults.Text = ""
Dim f As String = String.Empty

Dim t As Content.EmailTemplate
t = Content.EmailTemplate.FindByBvin(WebAppSettings.EmailTemplateID_ContactUs)

If t IsNot Nothing Then
Dim m As System.Net.Mail.MailMessage
m = t.ConvertToMailMessage(Me.FromEmailField.Text.Trim, Me.toEmailField.Text.Trim)

[red] =========
'when I put the following as you directed, it gives me a 404. Without that the script sends an empty email

Dim sw As System.IO.StringWriter = New System.IO.StringWriter()
Dim htw As HtmlTextWriter = New HtmlTextWriter(sw)
GridView1.RenderControl(htw)
Dim wishListHtml As String = sw.ToString()

m.body = wishlistHTML

==========[/red]

If Utilities.MailServices.SendMail(m) = False Then
lblErrorMessage.Text = "Error while sending mail!"
lblErrorMessage.Visible = True
Else
lblResults.Text = "Thank you. Your message has been sent."
End If
End If
End Sub

End Class [/blue]

Here is aspx code if you would like to see, It pulls the the image and link with hyperlinks.

[blue]<%@ Register Assembly="Anthem" Namespace="Anthem" TagPrefix="anthem" %>
<asp:Content ID="Content1" ContentPlaceHolderID="BvcPopupContentPlaceholder" Runat="Server">
<H3>Share your Wish List With Your Friends</H3>
<asp:Label id="lblErrorMessage" Runat="server" CssClass="errormessage" Visible="false" ></asp:Label>
<asp:ValidationSummary id="valSummary" Runat="server" ForeColor="" EnableClientScript="True" CssClass="errormessage"></asp:ValidationSummary>
<strong><asp:Label id="lblResults" Runat="server" CssClass="SuccessMessage"></asp:Label></strong>
<TABLE cellSpacing="0" cellPadding="5" width="100%" border="0">
<TR>
<TD class="FormLabel" vAlign="top" align="right">Your Email:</TD>
<TD vAlign="top" align="left">
<asp:Textbox id="FromEmailField" runat="server" Columns="30"></asp:Textbox> 
<bvc5:BVRequiredFieldValidator id="Requiredfieldvalidator1" Visible="True" Runat="server" ForeColor=" " EnableClientScript="True"
CssClass="errormessage" ErrorMessage="Please enter an email address" Display="Dynamic" ControlToValidate="FromEmailField">*</bvc5:BVRequiredFieldValidator>
<bvc5:BVRegularExpressionValidator id="Regularexpressionvalidator1" Runat="server" ForeColor=" " CssClass="errormessage"
ErrorMessage="Please enter a valid email address" Display="Dynamic" ControlToValidate="FromEmailField" ValidationExpression="^(([A-Za-z0-9]+_+)|([A-Za-z0-9]+\-+)|([A-Za-z0-9]+\.+)|([A-Za-z0-9]+\++))*[A-Za-z0-9]+@((\w+\-+)|(\w+\.))*\w{1,63}\.[a-zA-Z]{2,6}$"></bvc5:BVRegularExpressionValidator></TD>
</TR>
<TR>
<TD class="FormLabel" vAlign="top" align="right">Friend's Email:</TD>
<TD vAlign="top" align="left">
<asp:Textbox id="toEmailField" runat="server" Columns="30"></asp:Textbox> 
<bvc5:BVRequiredFieldValidator id="valEmail" Visible="True" Runat="server" ForeColor=" " EnableClientScript="True"
CssClass="errormessage" ErrorMessage="Please enter an email address" Display="Dynamic" ControlToValidate="ToEmailField">*</bvc5:BVRequiredFieldValidator>
<bvc5:BVRegularExpressionValidator id="valEmail2" Runat="server" ForeColor=" " CssClass="errormessage" ErrorMessage="Please enter a valid email address"
Display="Dynamic" ControlToValidate="ToEmailField" ValidationExpression="^(([A-Za-z0-9]+_+)|([A-Za-z0-9]+\-+)|([A-Za-z0-9]+\.+)|([A-Za-z0-9]+\++))*[A-Za-z0-9]+@((\w+\-+)|(\w+\.))*\w{1,63}\.[a-zA-Z]{2,6}$"></bvc5:BVRegularExpressionValidator></TD>
</TR>
<TR>
<TD vAlign="top" align="left"> </TD>
<TD vAlign="top" align="left">
<asp:ImageButton id="btnSend" runat="server" ImageUrl="~/BVModules/Themes/Bvc5/images/buttons/submit.png"></asp:ImageButton></TD>
</TR>
</TABLE>
<asp:Textbox id="inMessage" runat="server" Visible="False" Columns="50"></asp:Textbox>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="bvin"
BorderColor="#CCCCCC" CellPadding="2" GridLines="None" Width="100%">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<div class="wishlistproductimage"><asp:HyperLink ID="imgProduct" runat="server"></asp:HyperLink></div>
<div class="wishlistproductlink"><asp:HyperLink ID="lnkProduct" runat="server"></asp:HyperLink></div>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</asp:Content>[/blue]
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

©2024 Develisys. All rights reserved.
  • Toll-free  888-665-8637
  • International  +1 717-220-0012