using System; using System.Diagnostics; using System.Reflection; using System.Threading.Tasks; namespace ConsoleApplication1 { class Program { private String Output { get; set; } static void Main(string[] args) { var p = new Program(); var stopwatch = new Stopwatch(); stopwatch.Start(); p.TestNormal(stopwatch); stopwatch.Restart(); p.TestNormalPlinq(stopwatch); stopwatch.Restart(); p.TestReflection(stopwatch); stopwatch.Restart(); p.TestReflectionCached(stopwatch); stopwatch.Restart(); p.TestReflectionCachedPlinq(stopwatch); } string ReturnDate() { return DateTime.Now.ToString(); } void TestNormal(Stopwatch stopwatch) { this.Output = DateTime.Now.ToString(); for (int x = 0; x < 200000; x++) { // *** Get Property Test - note we have to set the value here or else the compiler will optimize the assignment this.Output = DateTime.Now.ToString(); var Value = this.Output; // *** Set Property Test this.Output = DateTime.Now.ToString(); this.Output = this.ReturnDate(); } Debug.WriteLine("Normal test used: " + stopwatch.ElapsedMilliseconds + "ms"); } void TestNormalPlinq(Stopwatch stopwatch) { this.Output = DateTime.Now.ToString(); Parallel.For(0, 200000, (i) => { // *** Get Property Test - note we have to set the value here or else the compiler will optimize the assignment this.Output = DateTime.Now.ToString(); var Value = this.Output; // *** Set Property Test this.Output = DateTime.Now.ToString(); this.Output = this.ReturnDate(); }); Debug.WriteLine("NormalPlinq test used: " + stopwatch.ElapsedMilliseconds + "ms"); } void TestReflection(Stopwatch stopwatch) { for (int x = 0; x < 200000; x++) { this.Output = DateTime.Now.ToString(); string Value = (string) this.GetType().GetProperty("Output", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(this, null); //,BindingFlags.Instance | BindingFlags.NonPublic,null,null); // *** Set Property Test this.GetType().GetProperty("Output", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(this, DateTime.Now.ToString(), null); //,BindingFlags.Instance | BindingFlags.NonPublic,null,null); string value = (string) this.GetType().GetMethod("ReturnDate", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(this, null); } Debug.WriteLine("Reflect test used: " + stopwatch.ElapsedMilliseconds + "ms"); } void TestReflectionCached(Stopwatch stopwatch) { var pi = this.GetType().GetProperty("Output", BindingFlags.Instance | BindingFlags.NonPublic); var mi = this.GetType().GetMethod("ReturnDate", BindingFlags.Instance | BindingFlags.NonPublic); Func<string> getter = () => (string) pi.GetValue(this, null); Action<string> setter = (s) => pi.SetValue(this, s, null); Func<string> getMethod = () => (string) mi.Invoke(this, null); for (int x = 0; x < 200000; x++) { this.Output = DateTime.Now.ToString(); string Value = getter(); setter(DateTime.Now.ToString()); string value = getMethod(); } Debug.WriteLine("ReflectCache test used: " + stopwatch.ElapsedMilliseconds + "ms"); } void TestReflectionCachedPlinq(Stopwatch stopwatch) { var pi = this.GetType().GetProperty("Output", BindingFlags.Instance | BindingFlags.NonPublic); var mi = this.GetType().GetMethod("ReturnDate", BindingFlags.Instance | BindingFlags.NonPublic); Func<string> getter = () => (string)pi.GetValue(this, null); Action<string> setter = (s) => pi.SetValue(this, s, null); Func<string> getMethod = () => (string)mi.Invoke(this, null); Parallel.For(0, 200000, (i) => { this.Output = DateTime.Now.ToString(); string Value = getter(); setter(DateTime.Now.ToString()); string value = getMethod(); }); Debug.WriteLine("ReflectCachePlinq test used: " + stopwatch.ElapsedMilliseconds + "ms"); } } }
<%@ Page Language="VB" Debug="true" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server" type="text/VB" language="vbscript"> Dim sSubPageName as string, sSectionName as string, sLinkName as string dim s as Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If IsPostBack Then ' statusMessage.Text &= "hi" end if statusMessage.Text &= sSectionName end sub </script> <html> ... </html>
public partial class Default_aspx : System.Web.UI.Page { protected DropDownList myDropDownListFix; protected void Page_Load( object sender, EventArgs e ) { // get a reference to the desired control Control myControl = FindControl("ctl00$Main$DropDownList1"); // make sure you have the right type if (myControl.GetType() == typeof(System.Web.UI.WebControls.DropDownList)) { // now safe to cast it to the one you want and work with it myDropDownListFix = (DropDownList)FindControl("ctl00$Main$DropDownList1"); myDropDownListFix.Items.Add("Me"); myDropDownListFix.Items.Add("You"); myDropDownListFix.Items.Add("Calib"); myDropDownListFix.Items.Add("The Horses"); } . . . .
var top = document.body.scrollTop || window.pageYOffset || (document.body.parentElement ? document.body.parentElement.scrollTop : 0 );
<ww:jQueryDatePicker ID="jQueryDatePicker1" Enabled=true runat="server" ></ww:jQueryDatePicker>
_updateDatepicker: function(inst) { inst._datepickerDiv.empty().append(inst._generateDatepicker()); if (inst._get('numberOfMonths') != 1) { inst._datepickerDiv.addClass('datepicker_multi'); } else { inst._datepickerDiv.removeClass('datepicker_multi'); } if (inst._input && inst._input[0].type != 'hidden') { inst._input[0].focus(); }