Request.QueryString help needed

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
User avatar
William_firefold
Commander (CMDR)
Commander (CMDR)
Posts: 186
Joined: Fri Aug 01, 2008 8:38 am

Request.QueryString help needed

Post by William_firefold » Tue Sep 29, 2009 1:18 pm

I have a conlib on the frontpage which loads products 200 at a time. It uses most of the code from the "featured products" conlib with minor adjustments:

Code: Select all

    protected void Page_Load(object sender, EventArgs e)
    {
        _GlobalDisablePurchase = Token.Instance.Store.Settings.ProductPurchasingDisabled;
        if (!string.IsNullOrEmpty(this.Caption)) CaptionLabel.Text = this.Caption;
        ProductList.RepeatColumns = this.Columns;
	pager=AlwaysConvert.ToInt(Request.QueryString["p"]);////////////////////
        ProductList.DataSource = ProductDataSource.LoadForStore(200,200* pager);//////////////////////
        ProductList.DataBind();
    }
I am having trouble figuring out how to make a link at the bottom of the page with http://_________/?p+1 (ie the next page) in the href field.

Code: Select all

<asp:HyperLink ID="nextlink" runat="server" NavigateUrl='<%# getnextpageurl()%>'>Next</asp:HyperLink>
wasnt working for me for some reason.
Anyone know how to do this? Maybe Im just not formatting my hyperlink properly. Any advice appreciated.

User avatar
AbleMods
Master Yoda
Master Yoda
Posts: 5170
Joined: Wed Sep 26, 2007 5:47 am
Location: Fort Myers, Florida USA

Re: Request.QueryString help needed

Post by AbleMods » Tue Sep 29, 2009 2:13 pm

Your hyperlink markup looks correct. Where's the code-behind for the getnextpageurl() function?
Joe Payne
AbleCommerce Custom Programming and Modules http://www.AbleMods.com/
AbleCommerce Hosting http://www.AbleModsHosting.com/
Precise Fishing and Hunting Time Tables http://www.Solunar.com

afm
Captain (CAPT)
Captain (CAPT)
Posts: 339
Joined: Thu Nov 03, 2005 11:52 pm
Location: Portland, OR
Contact:

Re: Request.QueryString help needed

Post by afm » Tue Sep 29, 2009 4:11 pm

Should it be <%= getnextpageurl()%> instead of <%# getnextpageurl()%>?

They both might work (or not work) if something is calling DataBind on the page, otherwise the %# syntax will never be resolved.
Andy Miller
Structured Solutions

Shipper 3 - High Velocity Shipment Processing

User avatar
William_firefold
Commander (CMDR)
Commander (CMDR)
Posts: 186
Joined: Fri Aug 01, 2008 8:38 am

Re: Request.QueryString help needed

Post by William_firefold » Wed Sep 30, 2009 5:51 am

This is the function I am trying to create:

Code: Select all


protected string getnextpageurl()
    {
	int pager=AlwaysConvert.ToInt(Request.QueryString["p"]);
        return "http://new.website.com/?p="+(pager+1).ToString();
    }
When i used <%= getnextpageurl()%>
It set the link address to this : http://new.website.com/ConLib/custom/<%= getnextpageurl() %>
When I use <%# getnextpageurl()%> the link has no address at all.

User avatar
AbleMods
Master Yoda
Master Yoda
Posts: 5170
Joined: Wed Sep 26, 2007 5:47 am
Location: Fort Myers, Florida USA

Re: Request.QueryString help needed

Post by AbleMods » Wed Sep 30, 2009 6:35 am

Hmmm I'm not sure the server-side hyperlink control supports substitution on the NavigateUrl.

Try leaving the NavigateUrl blank in the HTML and assigning it the correct value during Page_Load()

Code: Select all

.
.
.
int pager=AlwaysConvert.ToInt(Request.QueryString["p"]);
if (pager > 0)
   nextlink.NavigateUrl = "http://new.website.com/?p="+(pager+1).ToString();
else
   nextlink.Visible = false;
.
.
.
Joe Payne
AbleCommerce Custom Programming and Modules http://www.AbleMods.com/
AbleCommerce Hosting http://www.AbleModsHosting.com/
Precise Fishing and Hunting Time Tables http://www.Solunar.com

User avatar
William_firefold
Commander (CMDR)
Commander (CMDR)
Posts: 186
Joined: Fri Aug 01, 2008 8:38 am

Re: Request.QueryString help needed

Post by William_firefold » Wed Sep 30, 2009 6:55 am

That fixed it.
Thanks Joe.

User avatar
AbleMods
Master Yoda
Master Yoda
Posts: 5170
Joined: Wed Sep 26, 2007 5:47 am
Location: Fort Myers, Florida USA

Re: Request.QueryString help needed

Post by AbleMods » Wed Sep 30, 2009 7:59 am

Groovy
Joe Payne
AbleCommerce Custom Programming and Modules http://www.AbleMods.com/
AbleCommerce Hosting http://www.AbleModsHosting.com/
Precise Fishing and Hunting Time Tables http://www.Solunar.com

Post Reply