We would like to put an "AddToCart" button on the additional images page "ProductImages.aspx"
I have a conlib which is similar to AddToCartLink.ascx that I want to use, but whenever I add it to the page and register it, it doesnt even show up.
It shows in the source code but not on the page.
Any ideas?
Another AddToCart button
- William_firefold
- Commander (CMDR)
- Posts: 186
- Joined: Fri Aug 01, 2008 8:38 am
Re: Another AddToCart button
Make sure that you have saved the changes properly and there is no code hiding your control at run time. Its just a wild guess because the problem is in something custom and code view is necessary.
- William_firefold
- Commander (CMDR)
- Posts: 186
- Joined: Fri Aug 01, 2008 8:38 am
Re: Another AddToCart button
My conlib is just a copy of addtocartlink.aspx & .cs with a redirect at the end that will send the user to the cart. I want to add the button to productimages.aspx, which for some reason, was made as a complete page instead of a placeholder linking to a conlib.
Here is the productimages code we have:
And here is what I want to do:
My button never even shows up on the page. I tried visible=true and a few other things with no luck.
Here is the productimages code we have:
Code: Select all
<form id="form1" runat="server">
<ajax:ScriptManager ID="ScriptManager1" runat="server" />
<asp:UpdatePanel ID="ImageAjax" runat="server">
<ContentTemplate>
<span class="labelText"></span>
<div class="topButtons">
<asp:Label runat="Server" ID="Label1" />
<asp:Button runat="Server" ID="prevButton" Text="Previous Image" OnClick="prevButton_Click" />
<asp:Button runat="Server" ID="nextButton" Text="Next Image" OnClick="nextButton_Click" />
<asp:Button runat="Server" ID="closeButton" Text="Close Window" />
</div>
<asp:Label runat="Server" ID="imageLabel1" />
<asp:Image ID="Image1" runat="server" width="500px" height="500px" />
<div class="botButtons">
<asp:Label runat="Server" ID="Label2" />
<asp:Button runat="Server" ID="prevButtonBottom" Text="Previous Image" OnClick="prevButton_Click" />
<asp:Button runat="Server" ID="nextButtonBottom" Text="Next Image" OnClick="nextButton_Click" />
<asp:Button runat="Server" ID="closeButtonBottom" Text="Close Window" />
</div>
<asp:HiddenField runat="server" ID="PictureIndex" Value="0" />
</ContentTemplate>
</asp:UpdatePanel>
</form>
And here is what I want to do:
Code: Select all
<%@ Register Src="~/ConLib/AddToCartLinkRedirect.ascx" TagName="AddToCartLinkRedirect" TagPrefix="uc" %>
Code: Select all
////////////
protected int GetProdId(){ return _ProductId; }
///////////
<form id="form1" runat="server">
<ajax:ScriptManager ID="ScriptManager1" runat="server" />
<asp:UpdatePanel ID="ImageAjax" runat="server">
<ContentTemplate>
<span class="labelText"></span>
<div class="topButtons">
<asp:Label runat="Server" ID="Label1" />
<asp:Button runat="Server" ID="prevButton" Text="Previous Image" OnClick="prevButton_Click" />
<asp:Button runat="Server" ID="nextButton" Text="Next Image" OnClick="nextButton_Click" />
<asp:Button runat="Server" ID="closeButton" Text="Close Window" />
</div>
<asp:Label runat="Server" ID="imageLabel1" />
<asp:Image ID="Image1" runat="server" width="500px" height="500px" />
<div class="botButtons">
<asp:Label runat="Server" ID="Label2" />
<asp:Button runat="Server" ID="prevButtonBottom" Text="Previous Image" OnClick="prevButton_Click" />
<asp:Button runat="Server" ID="nextButtonBottom" Text="Next Image" OnClick="nextButton_Click" />
<asp:Button runat="Server" ID="closeButtonBottom" Text="Close Window" />
/////////////////
<uc:AddToCartLinkRedirect ID="AddToCartLinkRedirect1" runat="server" ProductId='<%# GetProdId() %>' />
////////////////
</div>
<asp:HiddenField runat="server" ID="PictureIndex" Value="0" />
</ContentTemplate>
</asp:UpdatePanel>
</form>
Re: Another AddToCart button
Seems like some custom view state problem. During the pre-render event the AddToCartLink gets product id as 0 and hence hides the link. Better you should update you custom control to use the product id from browser URL instead of having the custom view state as with the case with AddToCartLink. For example give a try to the following control I have created from AddToCartLink control by using the main code required to add product to cart all else was related to custom view state.
- William_firefold
- Commander (CMDR)
- Posts: 186
- Joined: Fri Aug 01, 2008 8:38 am
Re: Another AddToCart button
That worked very well. Thank you mazhar.
One thing though.
What is the proper way to do a window.close() and a parent window refresh in the Able system?
I tried everything google threw at me but Able hated every script.
One thing though.
What is the proper way to do a window.close() and a parent window refresh in the Able system?
I tried everything google threw at me but Able hated every script.
Re: Another AddToCart button
just call the close on the child window object or if you want to close the window by it self the call self.close()William_firefold wrote:That worked very well. Thank you mazhar.
What is the proper way to do a window.close()
For this you can use the window.opener.location.reload() statement.and a parent window refresh in the Able system?
I tried everything google threw at me but Able hated every script.
Below is the ProductImages.aspx page code with sample javascript calls. Just update the
ProductImages.aspx?ProductId=4 url by providing some product id that contains the additional images and then you can test the page. In order to test parent refresh by child. Open a child window by clicking the open button then select some different image for Parent window of ProductImages page then go to child window and click refresh you will notice the page refresh.
Code: Select all
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
private int _ProductId;
private Product _Product;
private int _ImageCount;
public int GetProductId()
{
return PageHelper.GetProductId();
}
protected void Page_Init(object sender, EventArgs e)
{
_ProductId = AlwaysConvert.ToInt(Request.QueryString["ProductId"]);
_Product = ProductDataSource.Load(_ProductId);
if (_Product != null)
{
Page.Title = string.Format(Page.Title, _Product.Name);
_ImageCount = _Product.Images.Count;
prevButton.Visible = (_ImageCount > 1);
nextButton.Visible = prevButton.Visible;
}
else
{
this.Controls.Clear();
}
}
protected void Page_PreRender(object sender, EventArgs e)
{
if (_Product != null)
{
int tempIndex = AlwaysConvert.ToInt(PictureIndex.Value);
if (tempIndex < 0) tempIndex = _ImageCount - 1;
if (tempIndex >= _ImageCount) tempIndex = 0;
PictureIndex.Value = tempIndex.ToString();
//UPDATE IMAGE
Image1.ImageUrl = ResolveUrl(_Product.Images[tempIndex].ImageUrl);
Image1.AlternateText = _Product.Images[tempIndex].ImageAltText;
closeButton.Attributes.Add("onclick", "self.close();");
closeButtonBottom.Attributes.Add("onclick", "self.close();");
}
}
protected void prevButton_Click(object sender, EventArgs e)
{
PictureIndex.Value = (AlwaysConvert.ToInt(PictureIndex.Value) - 1).ToString();
}
protected void nextButton_Click(object sender, EventArgs e)
{
PictureIndex.Value = (AlwaysConvert.ToInt(PictureIndex.Value) + 1).ToString();
}
protected void Page_PreInit(object sender, EventArgs e)
{
Page.Theme = Token.Instance.Store.Settings.StoreTheme;
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Images of {0}</title>
<script type="text/javascript" language="javascript">
var childWindow;
function openWindow()
{
childWindow = window.open("ProductImages.aspx?ProductId=4");
return false;
}
function closeWindow()
{
childWindow.close();
return false;
}
function refreshWindow()
{
window.opener.location.reload();
return false;
}
</script>
</head>
<body>
<form id="form1" runat="server">
<ajax:ScriptManager ID="ScriptManager1" runat="server" />
<asp:UpdatePanel ID="ImageAjax" runat="server">
<ContentTemplate>
<div style="text-align:center">
<asp:Label runat="Server" ID="Label1"/><br /><br />
<asp:Button runat="Server" ID="prevButton" Text="< Prev" OnClick="prevButton_Click" />
<asp:Button runat="Server" ID="nextButton" Text="Next >" OnClick="nextButton_Click" />
<asp:Button runat="Server" ID="closeButton" Text="Close" />
<asp:Label runat="Server" ID="imageLabel1"/><br /><br />
<asp:Image ID="Image1" runat="server"
Style="border: 1px solid black;width:auto" />
<asp:HiddenField runat="server" ID="PictureIndex" Value="0" />
<asp:Label runat="Server" ID="Label2"/><br /><br />
<asp:Button runat="Server" ID="prevButtonBottom" Text="< Prev" OnClick="prevButton_Click" />
<asp:Button runat="Server" ID="nextButtonBottom" Text="Next >" OnClick="nextButton_Click" />
<asp:Button runat="Server" ID="closeButtonBottom" Text="Close" />
<asp:Button runat="Server" ID="Button1" Text="Open" OnClientClick="return openWindow();" />
<asp:Button runat="Server" ID="Button2" Text="CloseChild" OnClientClick="return closeWindow();" />
<asp:Button runat="Server" ID="Button3" Text="Refresh" OnClientClick="return refreshWindow();" />
</div>
</ContentTemplate>
</asp:UpdatePanel>
</form>
</body>
</html>