ExtensionMethod.NET Home of 880 C#, Visual Basic, F# and Javascript extension methods

Generates a Hyper Link to redirect user to Authentication form

this method generates a Hyper Link to redirect user to Authentication form . gets Titla attribute of tag and inner Text of Tag and generate tag A . then returns user to referrer page .

Source

public static string SPUtilGenerateAuthenticationHyperLink(this Page p , string title , string InnerText)
{

    try
    {
        string url = p.Request.Url.Scheme + "://" + p.Request.Url.Authority + "/_layouts/Authenticate.aspx?Source=" + p.Request.Url.LocalPath;
        string Tag_A = "<a href=\"" + url + "\" title=\""+title+"\">" + InnerText + "</a>";
        return Tag_A;
    }
    catch
    {
        string Tag_A = "<a href=\"#ERROR\" title=\""+title+"\">" + InnerText + "</a>";

        return Tag_A;
    }
    
}

Example

string Tag_A = Page.SPUtilGenerateAuthenticationHyperLink("To Login Click Here", " Here ");
 lit_Msg.Text = "You are not logged in . please log in at first & click " + Tag_A + " to show Authentication Form";

Author: http://mb-seifollahi.ir

Submitted on: 6 apr. 2013

Language: C#

Type: System.String

Views: 5584