C# - Binding ComboBox with Enum
Bind the values of an enum to a WinForms ComboBox with a display name and a numeric key.
public enum RequestDept
{
CallCenter = 0,
Development = 1,
Enrollment = 2,
Implementation = 3,Articles, code snippets and news worth sharing.
Bind the values of an enum to a WinForms ComboBox with a display name and a numeric key.
public enum RequestDept
{
CallCenter = 0,
Development = 1,
Enrollment = 2,
Implementation = 3,Add a custom action to the Actions menu of a SharePoint survey list using a module in an empty SharePoint project.
<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<!-- Survey Actions Menu Dropdown -->
<CustomAction Id="6D6F6574-57CD-4BDD-88E5-9651A066140E"
RegistrationType="List"
Description="DescriptionGoesHere"Create a list field that appears on the display form but is hidden from the new and edit forms.
string newField = "<Field Type=\"Text\" MaxLength=\"50\" DisplayName=\"NewField\" Name=\"NewField\" ShowInNewForm=\"FALSE\" ShowInEditForm=\"FALSE\" />";
list.Fields.AddFieldAsXml(newField, true, SPAddFieldOptions.Default);Add the missing Sign in as Different User item to the SharePoint 2013 welcome menu by editing Welcome.ascx.
C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\TEMPLATE\CONTROLTEMPLATES\Welcome.ascxA sandbox solution cannot call Response.Redirect, so write a small script through a literal control instead.
<asp:Literal ID="litRedirect" runat="server" />Upload an attachment to a list item from a sandboxed visual web part by opening the AttachFile.aspx page in a modal dialog.
<script type="text/javascript">
function callback() {
alert('document uploaded');
}
function openPopup() {Escape single and double quotes in a string before an AJAX post, using a simple replace instead of encoding everything.
data.replace(/(['"])/g, "\\$1")Download a file in a Windows Store app with BackgroundDownloader and async/await in C#.
async Task<bool> DownloadFile(Uri source, StorageFile destination)
{
try
{
BackgroundDownloader downloader = new BackgroundDownloader();
DownloadOperation download =One line of JavaScript that reloads the current page from the server.
document.location.reload(true);Catch every unhandled JavaScript error on a page with window.onerror and show the message, URL and line number.
window.onerror = function(error, url, line) {
var errorDetails = "Error Description = " + error;
errorDetails += "\nUrl = " + url;
errorDetails += "\nLine Number = " + line;
alert(errorDetails);An async C# method that checks a URL is well formed and that the server answers, using a HEAD request.
private async Task<bool> UriExists(string url)
{
try
{
// Validate whether url has a valid uri pattern
if (!Uri.IsWellFormedUriString(url, UriKind.RelativeOrAbsolute))Three ways to set a tooltip on a control in a Windows Store app: the Properties window, XAML and code behind.
ToolTip textUriTip = new ToolTip();
textUriTip.Content = "New ToolTip";
ToolTipService.SetToolTip(usr, textUriTip);