Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions samples/BeforeWebForms/BeforeWebForms.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@
<Content Include="ControlSamples\GridView\AutoGeneratedColumns.aspx" />
<Content Include="ControlSamples\GridView\Default.aspx" />
<Content Include="ControlSamples\GridView\TemplateFields.aspx" />
<Content Include="ControlSamples\Hyperlink\default.aspx" />
<Content Include="ControlSamples\ListView\Grouping.aspx" />
<Content Include="ControlSamples\ListView\Default.aspx" />
<Content Include="ControlSamples\ListView\ModelBinding.aspx" />
Expand Down Expand Up @@ -238,6 +239,13 @@
<Compile Include="ControlSamples\GridView\TemplateFields.aspx.designer.cs">
<DependentUpon>TemplateFields.aspx</DependentUpon>
</Compile>
<Compile Include="ControlSamples\Hyperlink\default.aspx.cs">
<DependentUpon>default.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="ControlSamples\Hyperlink\default.aspx.designer.cs">
<DependentUpon>default.aspx</DependentUpon>
</Compile>
<Compile Include="ControlSamples\ListView\Grouping.aspx.cs">
<DependentUpon>Grouping.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
Expand Down
36 changes: 36 additions & 0 deletions samples/BeforeWebForms/ControlSamples/Hyperlink/default.aspx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="default.aspx.cs" Inherits="BeforeWebForms.ControlSamples.Hyperlink._default" MasterPageFile="~/Site.Master" %>

<asp:Content runat="server" ContentPlaceHolderID="MainContent">

<h2>Hyperlink Demos</h2>

<p>
This hyperlink has Style!

<asp:HyperLink runat="server" ID="styleLink" BackColor="Blue" ForeColor="White" Text="Blue Button" NavigateUrl="https://bing.com" />

</p>

<p>
This hyperlink has Tooltips!

<asp:HyperLink runat="server" ID="HyperLink1" Text="Blue Button" ToolTip="Navigate to Bing!" NavigateUrl="https://bing.com" />

</p>

<p>
This hyperlink is not visible

<asp:HyperLink runat="server" ID="HyperLink2" Text="Blue Button" Visible="false" NavigateUrl="https://bing.com" />

</p>

<p>

This hyperlink is DataBinding!

<asp:HyperLink runat="server" ID="HyperLink3" Text="Blue Button" OnDataBinding="HyperLink3_DataBinding" NavigateUrl="https://bing.com" />

</p>

</asp:Content>
22 changes: 22 additions & 0 deletions samples/BeforeWebForms/ControlSamples/Hyperlink/default.aspx.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace BeforeWebForms.ControlSamples.Hyperlink
{
public partial class _default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}

protected void HyperLink3_DataBinding(object sender, EventArgs e)
{

}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions samples/BeforeWebForms/Default.aspx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
<h3>Editor Controls</h3>
<ul>
<li><a href="ControlSamples/Button/Default.aspx">Button</a></li>
<li><a href="ControlSamples/Hyperlink/Default.aspx">Hyperlink</a></li>
</ul>
</div>

Expand Down
5 changes: 5 additions & 0 deletions samples/BeforeWebForms/Site.Master
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@
<asp:TreeNode NavigateUrl="ControlSamples/Repeater/Default.aspx" Text=" Repeater" Expanded="true" />
</asp:TreeNode>

<asp:TreeNode Text=" Editor Components" Expanded="true">
<asp:TreeNode Text=" Button" NavigateUrl="~/ControlSamples/Button/default.aspx" />
<asp:TreeNode Text=" Hyperlink" NavigateUrl="~/ControlSamples/Hyperlink/default.aspx" />
</asp:TreeNode>

<asp:TreeNode Text=" Validation Components" Expanded="false">
<asp:TreeNode Text=" Custom Validator" />
<asp:TreeNode Text=" Regular Expression" />
Expand Down
74 changes: 74 additions & 0 deletions src/BlazorWebFormsComponents.Test/HyperLink/Style.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
@inherits TestComponentBase
@using static BlazorWebFormsComponents.WebColor
@using static BlazorWebFormsComponents.Enums.BorderStyle
@using BlazorWebFormsComponents

<Fixture Test="HyperLink_Style">
<ComponentUnderTest>
<HyperLink Text="Blue Button" NavigationUrl="https://bing.com" BackColor="Blue" ForeColor="White" />
</ComponentUnderTest>

@code {
void HyperLink_Style(Fixture fixture)
{

var cut = fixture.GetComponentUnderTest();

cut.Find("a").HasAttribute("style").ShouldBeTrue();
var style = cut.Find("a").GetAttribute("style");

style.ShouldNotBeNull();
style.ShouldContain("background-color:Blue");
style.ShouldContain("color:White");

}
}

</Fixture>

<Fixture Test="HyperLink_Tooltip">
<ComponentUnderTest>
<HyperLink Text="Blue Button" NavigationUrl="https://bing.com" ToolTip="@RandomTooltip" />
</ComponentUnderTest>

@code {

private string RandomTooltip = new Random(828).Next(10000, 1000000).ToString();


void HyperLink_Tooltip(Fixture fixture)
{

var cut = fixture.GetComponentUnderTest();

cut.Find("a").HasAttribute("title").ShouldBeTrue();
var attr = cut.Find("a").GetAttribute("title");

attr.ShouldNotBeNull();
attr.ShouldBe(RandomTooltip);

}

}
</Fixture>

<Fixture Test="HyperLink_Visible">
<ComponentUnderTest>
<HyperLink Text="Blue Button" NavigationUrl="https://bing.com" Visible="false" />
</ComponentUnderTest>

@code {

void HyperLink_Visible(Fixture fixture)
{

var cut = fixture.GetComponentUnderTest();

cut.FindAll("a").Count().ShouldBe(0, "Still rendered the anchor even though its not visible");

}

}
</Fixture>


17 changes: 11 additions & 6 deletions src/BlazorWebFormsComponents/HyperLink.razor
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
@inherits BaseWebFormsComponent

@if (NavigationUrl == null)
@if (Visible)
{
<a id="@ID">@Text</a>
}
else
{
<a id="@ID" target="@Target" href="@NavigationUrl">@Text</a>

@if (NavigationUrl == null)
{
<a id="@ID" class="@CssClass" style="@CalculatedStyle" title="@ToolTip">@Text</a>
}
else
{
<a id="@ID" href="@NavigationUrl" target="@Target" title="@ToolTip" class="@CssClass" style="@CalculatedStyle">@Text</a>
}

}
29 changes: 26 additions & 3 deletions src/BlazorWebFormsComponents/HyperLink.razor.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,39 @@
using Microsoft.AspNetCore.Components;
using BlazorComponentUtilities;
using BlazorWebFormsComponents.Enums;
using Microsoft.AspNetCore.Components;

namespace BlazorWebFormsComponents
{
public partial class HyperLink : BaseWebFormsComponent
public partial class HyperLink : BaseWebFormsComponent, IHasStyle
{
[Parameter]
public string NavigationUrl { get; set; }

[Parameter]
public string Target { get; set; } = string.Empty;

[Parameter]
[Parameter]
public string Text { get; set; }

[Parameter] public string ToolTip { get; set; }

[Parameter] public WebColor BackColor { get; set; }
[Parameter] public WebColor BorderColor { get; set; }
[Parameter] public BorderStyle BorderStyle { get; set; }
[Parameter] public Unit BorderWidth { get; set; }
[Parameter] public string CssClass { get; set; }
[Parameter] public WebColor ForeColor { get; set; }
[Parameter] public Unit Height { get; set; }
[Parameter] public Unit Width { get; set; }
[Parameter] public bool Font_Bold { get; set; }
[Parameter] public bool Font_Italic { get; set; }
[Parameter] public string Font_Names { get; set; }
[Parameter] public bool Font_Overline { get; set; }
[Parameter] public FontUnit Font_Size { get; set; }
[Parameter] public bool Font_Strikeout { get; set; }
[Parameter] public bool Font_Underline { get; set; }

private string CalculatedStyle => this.ToStyle().Build().NullIfEmpty();

}
}