Visual C# Button to implement into SharePoint

  • Thread starter Thread starter mstgier
  • Start date Start date
M

mstgier

Guest
Dear Pros,

I am moved around, regarding creating a Button in SharePoint.

After talking to some SharePoint people, they recommended to build the button with VisualStudio.

I have unfortunately no experience with VisualStudio nor with C# and to import on such way, that it works.

I was able to build my button for a test and it was running.

Then I opened a new project in VisualStudio - "SharePoint 2016 Visual Web Part" and copied my C# line at the end. (see code at the end)

Trying to add the web part in SharePoint, I get the following message:

$Resources:core,ImportErrorMessage;

At the end, I do not mind, if the code is written in C# or C++ or something similar (I anyway need to learn any language), as long as it is working in SharePoint. Maybe for SharePoint, there is it's own language?

What I will need at the end is, to open a PowerShell file by pressing a button on a sharepoint site and it will open(locally on the host and not on the server) that will be the long term target, that is why I am trying now to play around with notepad as a start.

Can anyone please help me, to explain to me, how I can implement such a button into SharePoint?

Thank you very much,

Mike



<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
<%@ Assembly Name="Microsoft.Web.CommandUI, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="VisualWebPart1.ascx.cs" Inherits="VisualWebPartProject2.VisualWebPart1.VisualWebPart1" %>
using System.Windows.Forms;
using System.Diagnostics;

namespace WindowsFormsApp1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
Process.Start(@"C:\Windows\notepad.exe");
}

private void Form1_Load(object sender, EventArgs e)
{

}
}
}

Continue reading...
 
Back
Top