Skip to content

Commit

Permalink
Updated VisualButton to support a text link alternative
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Palmhøj Nielsen committed Feb 22, 2013
1 parent 5394aff commit d641f17
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 9 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
.DS_Store
.DS_Store
src/*/obj
src/*/bin
Binary file modified dist/VisualSharepoint.wsp
Binary file not shown.
Binary file modified src/VisualSharepoint.suo
Binary file not shown.
1 change: 0 additions & 1 deletion src/VisualSharepoint/VisualSharepoint.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
<Reference Include="23API, Version=1.1.0.0, Culture=neutral, PublicKeyToken=c691d74182a532de, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Dependencies\23API.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="DotNetOpenAuth, Version=3.4.5.10202, Culture=neutral, PublicKeyToken=2780ccd10d57b246, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
Expand Down
Binary file modified src/VisualSharepoint/VisualSharepoint.wsp
Binary file not shown.
38 changes: 31 additions & 7 deletions src/VisualSharepoint/WebPartCode/VisualButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,28 @@ public class VisualButton : Microsoft.SharePoint.WebPartPages.WebPart
private string _buttonValue;
[WebBrowsable(true),
Personalizable(PersonalizationScope.Shared),
WebDescription("Launch button value"),
WebDescription("Button / Link Text"),
Category("Settings"),
WebDisplayName("Launch button value")]
WebDisplayName("Button / Link Text")]
public string ButtonValue
{
get { return _buttonValue; }
set { _buttonValue = value; }
}

private bool _useTextLink;
[WebBrowsable(true),
DefaultValue(false),
Personalizable(PersonalizationScope.Shared),
WebDescription("Use text link"),
Category("Settings"),
WebDisplayName("Use text link")]
public bool UseTextLink
{
get { return _useTextLink; }
set { _useTextLink = value; }
}

public VisualButton()
{
this.ExportMode = WebPartExportMode.All;
Expand Down Expand Up @@ -54,11 +67,22 @@ protected override void CreateChildControls()
this.Controls.Add(containerControl);

// Create the button control
HtmlGenericControl buttonControl = new HtmlGenericControl("input");
buttonControl.Attributes["type"] = "button";
buttonControl.Attributes["onclick"] = "javascript:location.href='" + buttonUri + "';";
buttonControl.Attributes["value"] = (!String.IsNullOrEmpty(_buttonValue) ? _buttonValue.Replace("\"", "&quot;") : "Launch");
containerControl.Controls.Add(buttonControl);
if (_useTextLink)
{
string linkText = (!String.IsNullOrEmpty(_buttonValue) ? _buttonValue.Replace("\"", "&quot;") : "Launch");
string link = "<a href='" + buttonUri + "'>" + linkText + "</a>";
LiteralControl linkControl = new LiteralControl(link);
containerControl.Controls.Add(linkControl);

}
else
{
HtmlGenericControl buttonControl = new HtmlGenericControl("input");
buttonControl.Attributes["type"] = "button";
buttonControl.Attributes["onclick"] = "javascript:location.href='" + buttonUri + "';";
buttonControl.Attributes["value"] = (!String.IsNullOrEmpty(_buttonValue) ? _buttonValue.Replace("\"", "&quot;") : "Launch");
containerControl.Controls.Add(buttonControl);
}
}
catch (Exception ex)
{
Expand Down

0 comments on commit d641f17

Please sign in to comment.