Solved

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

Posted on 2011-03-03
4
371 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
Comment Utility
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
Comment Utility
The page_load event gets an error saying that not all paths return a value
0
 
LVL 52

Expert Comment

by:Carl Tawn
Comment Utility
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
Comment Utility
Thanks for the help
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Bit flags and bit flag manipulation is perhaps one of the most underrated strategies in programming, likely because most programmers developing in high-level languages rely too much on the high-level features, and forget about the low-level ones. Th…
Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
This video discusses moving either the default database or any database to a new volume.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

771 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

15 Experts available now in Live!

Get 1:1 Help Now