Solved

Using HyperLink to pass values based on code behind variables

Posted on 2010-11-23
2
467 Views
Last Modified: 2012-05-10
Hi All

I have a hyperlink that links to the same page itself.
<asp:HyperLink ID="hyprNextMonth" runat="server" NavigateUrl="~/Calendar.aspx?M=" + <%=theCalendarDate.AddMonths(-1) %> ImageUrl="images/arrow_right.gif"/>

I'm trying to pass the next month int  in the NavigateUrl but can't get the code right.
Is there a better way of posting back to the same form as in PostBackURL or viewstate if so please show me how.

Thanks
0
Comment
Question by:iftech
2 Comments
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 500 total points
ID: 34199417
It would easier to do what you want from code-behind by dynamically setting the NavigateUrl from code. If you want to do it in markup you could use:

   NavigateUrl='<%# "~/Calendar.aspx?M=" + theCalendarDate.AddMonths(-1) %>'

But if you did that you would have to call DataBind() on the hyperlink from code-behind anyway. Also the code will probably blow up as you have it anyway probably complaining about the format of the URL.
0
 

Author Closing Comment

by:iftech
ID: 34200053
I used code behind to set NavigationURL
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

680 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question