Solved

Using HyperLink to pass values based on code behind variables

Posted on 2010-11-23
2
445 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
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…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

947 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now