Solved

Returning a simple link from a C# code behind page to the default.aspx page

Posted on 2011-03-03
4
373 Views
Last Modified: 2012-08-14
I have a very simple web app, if you want to call it that, that I have to make for a third party vendor.  They have sent us a .dll.  I have it loaded into my project fine.  I need to reference it on the page_load event retreive an encrypted link and return that link to the default.aspx page.  Can someone help me with this.  Below is what I have thus far.
The URL control on my default.aspx page
-----------------------------
<asp:HyperLink ID="HyperLink1" runat="server">Click Here</asp:HyperLink>

from the code behind page
-----------------------------
using HC.Ope.Security;

namespace SSOorgChart
{
    public partial class _Default : System.Web.UI.Page
    {
        
        protected string Page_Load(object sender, EventArgs e)
        {

 
                //OPEEncrypter.EncryptData("mpatton", "123412341234134");
                string keyToken = "aXsDKUI98ILKi";
                string userId = "userid";
                string hyperLink = OPEEncrypter.EncryptData(userId, keyToken);

                return HyperLink1.NavigateUrl;

        }
    }
}

Open in new window

0
Comment
Question by:jmpatton
  • 2
  • 2
4 Comments
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 500 total points
ID: 35027325
If Hyperlink1 is the control on your page and the variable "hyperLink" contains the url you want to link to, then you just need to change:
return HyperLink1.NavigateUrl;

Open in new window

To:
HyperLink1.NavigateUrl = hyperLink;

Open in new window

0
 

Author Comment

by:jmpatton
ID: 35027358
The page_load event gets an error saying that not all paths return a value
0
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 35027426
Page_Load is an event and doesn't return anything (event handlers always return void).

So instead of:
protected string Page_Load(object sender, EventArgs e)

Open in new window

It should be declared as:
protected void Page_Load(object sender, EventArgs e)

Open in new window

0
 

Author Closing Comment

by:jmpatton
ID: 35027658
Thanks for the help
0

Featured Post

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Suggested Solutions

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
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.

770 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