This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function S4() { | |
return (((1+Math.random())*0x10000)|0).toString(16).substring(1); | |
} | |
function guid() { | |
return (S4()+S4()+"-"+S4()+"-"+S4()+"-"+S4()+"-"+S4()+S4()+S4()); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[C#]Open in popup windowpublic class MyTemplate : ITemplate | |
{ | |
public void InstantiateIn(Control container) | |
{ | |
HyperLink link = new HyperLink(); | |
link.Text = DataBinder.Eval(container, "DataItem.Id").ToString(); | |
link.NavigateUrl = "javascript:alert('" + DataBinder.Eval(container, "DataItem.Id").ToString() + "');"; | |
container.Controls.Add(link); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[C#]Open in popup windowpublic class MyTemplate : ITemplate | |
{ | |
public void InstantiateIn(Control container) | |
{ | |
HtmlAnchor control = new HtmlAnchor(); | |
control.Name = "Hyper1"; | |
control.Attributes.Add("onclick", "alert('dd')"); | |
container.controls.Add(control); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var records = []; store.each(function(r){ records.push(r.copy()); }); var store2 = new Ext.data.Store({ recordType: store.recordType }); store2.add(records); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Define the name and type of the client script on the page. | |
String csName = "ButtonClickScript"; | |
Type csType = this.GetType(); | |
// Get a ClientScriptManager reference from the Page class. | |
ClientScriptManager cs = Page.ClientScript; | |
// Check to see if the client script is already registered. | |
if (!cs.IsClientScriptBlockRegistered(csType, csName)) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Read a page's GET URL variables and return them as an associative array. | |
function getUrlVars() | |
{ | |
var vars = [], hash; | |
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&'); | |
for(var i = 0; i < hashes.length; i++) | |
{ | |
hash = hashes[i].split('='); | |
vars.push(hash[0]); | |
vars[hash[0]] = hash[1]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class EnumerableExtension | |
{ | |
public static T PickRandom<T>(this IEnumerable<T> source) | |
{ | |
return source.PickRandom(1).Single(); | |
} | |
public static IEnumerable<T> PickRandom<T>(this IEnumerable<T> source, int count) | |
{ | |
return source.Shuffle().Take(count); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
List<Task<bool>> tasks = servers.Select(s => Task<bool>.Factory.StartNew(server => CallServer((string)server), s)).ToList(); | |
bool result; | |
do { | |
int idx = Task.WaitAny(tasks.ToArray()); | |
result = tasks[idx].Result; | |
tasks.RemoveAt(idx); | |
} while (!result && tasks.Count > 0); | |
// cancel other tasks |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$().jquery |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var b=document.body;if(b){void(z=document.createElement('script'));void(z.type='text/javascript');void(z.src='http://code.jquery.com/jquery-latest.min.js');void(b.appendChild(z));}else{} |