Format:
Recent snippets for: Rick Strahl
/// <summary> /// Creates a COM instance from a ProgID. Loads either /// Exe or DLL servers. /// </summary> /// <param name="progId"></param> /// <returns></returns> public static object CreateComInstance(string progId) { Type type = Type.GetTypeFromProgID(progId);
13 Views
no comments
/// <summary> /// Turns a string into a typed value generically. /// Explicitly assigns common types and falls back /// on using type converters for unhandled types. /// /// Common uses: /// * UI -> to data conversions /// * Parsers /// <seealso>Class ReflectionUtils</seealso> /// </summary>
427 Views
no comments
static string base36Chars = "0123456789abcdefghijklmnopqrstuvwxyz"; static char[] base36CharArray = base36Chars.ToCharArray(); /// <summary> /// Encodes an integer into a string by mapping to alpha and digits (36 chars) /// chars are embedded as lower case /// /// Example: 4zx12ss /// </summary>
324 Views
no comments
function copyToClipboard(e) { $('#CodeDisplay').editable(); $('#_contenteditor') .focus() .select() .keydown(function(e) { // capture Ctl-C, Ctl-X, ESC to remove editable if (e.which == 99 || e.which == 120 || e.which == 27) { // have to delay so text doesn't go away before copy operation setTimeout( function() { $("#CodeDisplay").editable("cleanup") },500);
97 Views
no comments
************************************************************************ * wwProcess :: GetUrlBasePath **************************************** *** Function: Method responsible for establishing the base path *** for this application. *** Assume: *** Pass: *** Return: ************************************************************************ FUNCTION GetUrlBasePath()
41 Views
no comments
/// <summary> /// Allows setting of a value in a UrlEncoded string. If the key doesn't exist /// a new one is set, if it exists it's replaced with the new value. /// </summary> /// <param name="urlEncoded">A UrlEncoded string of key value pairs</param> /// <param name="key"></param> /// <param name="value"></param> /// <returns></returns> public static string SetUrlEncodedKey(string urlEncoded, string key, string value) {
203 Views
no comments
#include wconnect.h SET PROCEDURE TO wwXmlState.prg ADDITIVE #IF .F. && Sample code CLEAR oState = CREATEOBJECT("wwXMLState") oState.LoadXML(FULLPATH( "test.xml"),.T.)
155 Views
2 comments
/// <summary> /// A semi-generic Response Filter that allows transformations /// to be easily hooked up easily via a TransformStream event /// </summary> public class TransformResponseFilter : Stream { /// <summary> /// The original stream /// </summary> Stream _stream;
197 Views
no comments
/// <summary> /// Summary description for ResponseFilter. /// </summary> public partial class ResponseFilter : System.Web.UI.Page { protected System.Web.UI.HtmlControls.HtmlForm Form1; protected System.Web.UI.WebControls.TextBox TextBox1; protected void Page_Load(object sender, System.EventArgs e) {
223 Views
no comments
var sel =
$("#gdEntries>tbody>tr")
.not(":first-child") // no header
.not(":last-child") // no footer
.filter(":even")
.addClass("gridalternate");
// *** Demonstrate simple plugin
sel.fadeTo(2000,0.30);
53 Views
no comments
IServiceProvider provider = (IServiceProvider)HttpContext.Current.Context;
HttpWorkerRequest worker = (HttpWorkerRequest)provider.GetService(typeof(HttpWorkerRequest));
44 Views
no comments
/// <summary> /// Returns an application Url that's Theme relative. /// images/users.gif /// returns: /myapp/app_themes/{activetheme}/images/users.gif /// </summary> public static string ResolveThemeUrl(string themeRelativePath) { string theme = null; // try to pick up active theme
44 Views
no comments
public class ListUtils { /// <summary> /// Manual ComboBox binding and adding a first item /// /// Assumes you're binding to an enumerable list of some sort /// and you're binding to Properties (not fields) /// </summary> public static void BindWithFirstItem(IEnumerable items, ComboBox listBox,
210 Views
1 comments
<div class="toolbarcontainer"> <a href="./" class="hoverbutton"><img src="css/images/home.gif" /> Home</a> | <a href="«Link(Page Name)».aspx"><img src="css/images/refresh.gif" /> Refresh Page</a> </div> <ww:ErrorDisplay runat="server" id="ErrorDisplay" /> <div class="containercontent"> «Marker» </div>
54 Views
no comments
// works as expected public wws_Item LoadBySku(string sku) { Expression< Func<wws_Item, bool> > func = itm => itm.Sku == sku; Entity = Context.wws_Items.Where(func).SingleOrDefault(); if (Entity != null) OnLoaded(Entity); return this.Entity;
174 Views
no comments
<%@Page language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <link rel="stylesheet" type="text/css" href="../westwind.css" /> <title>Web Connection Adminstration</title> <style type="text/css"> .containercontent { padding: 10px;
171 Views
no comments
StockContext context = new StockContext(); User user = context.Users.Where( uss => uss.Pk == 1).SingleOrDefault(); Response.Write(user.FullName + "<br>"); user.FullName = user.FullName + "!"; StockContext context2 = new StockContext(); User user2 = context.Users.Where(uss => uss.Pk == 1).SingleOrDefault(); Response.Write(user2.FullName + "<br>"); user2.FullName = user2.FullName + "!";
78 Views
no comments
public void LogSnippetViewAsync(string snippetId, string ipAddress, string userAgent) { Func<string, string, string, bool> del = this.LogSnippetView; del.BeginInvoke(snippetId, ipAddress,userAgent,null,null); } public bool LogSnippetView(string snippetId, string ipAddress, string userAgent) { if (string.IsNullOrEmpty(userAgent)) return false;
175 Views
no comments
public class SecurityUtils { const int LOGON32_LOGON_INTERACTIVE = 2; const int LOGON32_LOGON_NETWORK = 3; const int LOGON32_LOGON_BATCH = 4; const int LOGON32_LOGON_SERVICE = 5; const int LOGON32_LOGON_UNLOCK = 7; const int LOGON32_LOGON_NETWORK_CLEARTEXT = 8; const int LOGON32_LOGON_NEW_CREDENTIALS = 9;
78 Views
no comments
private void GetResourceSet() { this.ResourceSet = Request.Form[this.lstResourceSet.UniqueID]; if (ResourceSet == null) this.ResourceSet = Request.QueryString["ResourceSet"]; if (this.ResourceSet == null) this.ResourceSet = ViewState["ResourceSet"] as string; if (this.ResourceSet == null) this.ResourceSet = "";
182 Views
no comments
if (JSON && !JSON.parseWithDate) { var reISO = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/; var reMsAjax = /^\/Date\((d|-|.*)\)[\/|\\]$/; JSON.parseWithDate = function(json) { /// <summary> /// parses a JSON string and turns ISO or MSAJAX date strings /// into native JS date objects /// </summary> /// <param name="json" type="var">json with dates to parse</param>
165 Views
no comments
[TestClass] public class DateConversionTests { public DateConversionTests() { } [TestMethod] public void AjaxDate_IsoDate_DataContract_DeserializationTest()
221 Views
no comments
.smallprogress,.smallprogressright { width: 16px; height: 16px; background-image: url(images/loading_small.gif); background-repeat: no-repeat; display: inline-block; xdisplay: none; } .smallprogressright { float: right }
90 Views
no comments
error: function(xhr, status) { var err = null; if (xhr.readyState == 4) { var res = xhr.responseText; if (res && res.substr(0,1) == '{') var err = JSON.parseWithDate(res); if (!err) { if (xhr.status && xhr.status != 200) err = new CallbackException(xhr.status + " " + xhr.statusText);
145 Views
no comments
public static string GetFullApplicationPath() { var url = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority); return url + HttpContext.Current.Request.ApplicationPath.TrimEnd('/'); }
74 Views
no comments
Subscribe
Discuss
What's new
What is it
New Snippet
Recent Snippets
My Snippets
Web Code
Search
