Search Results

Search found 818 results on 33 pages for 'onload'.

Page 7/33 | < Previous Page | 3 4 5 6 7 8 9 10 11 12 13 14  | Next Page >

  • Please help with System.Runtime.InteropServices.SEHException: External component has thrown an excep

    - by Brandon
    My aspx page gives me this error sometimes: External component has thrown an exception. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Runtime.InteropServices.SEHException: External component has thrown an exception. Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Stack Trace: [SEHException (0x80004005): External component has thrown an exception.] Luxand.FSDK.Initialize(String DataFilesPath) +0 WebService.onLoad() +70 WebService..ctor() +91 facematch.Page_Load(Object sender, EventArgs e) +50 System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15 System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +33 System.Web.UI.Control.OnLoad(EventArgs e) +99 System.Web.UI.Control.LoadRecursive() +47 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1436

    Read the article

  • Order of operations to render VBO to FBO texture and then rendering FBO texture full quad

    - by cyberdemon
    I've just started using OpenGL with C# via the OpenTK library. I've managed to successfully render my game world using VBOs. I now want to create a pixellated affect by rendering the frame to an offscreen FBO with a size half of my GameWindow size and then render that FBO to a full screen quad. I've been looking at the OpenTK example here: http://www.opentk.com/doc/graphics/frame-buffer-objects ...but the result is a black form. I'm not sure which parts of the example code belongs in the OnLoad event and OnRenderFrame. Can someone please tell me if the below code shows the correct order of operations? OnLoad { // VBO. // DataArrayBuffer GenBuffers/BindBuffer/BufferData // ElementArrayBuffer GenBuffers/BindBuffer/BufferData // ColourArrayBuffer GenBuffers/BindBuffer/BufferData // FBO. // ColourTexture GenTextures/BindTexture/TexParameterx4/TexImage2D // Create FBO. // Textures Ext.GenFramebuffers/Ext.BindFramebuffer/Ext.FramebufferTexture2D/Ext.FramebufferRenderbuffer } OnRenderFrame { // Use FBO buffer. Ext.BindFramebuffer(FBO) GL.Clear // Set viewport to FBO dimensions. GL.DrawBuffer((DrawBufferMode)FramebufferAttachment.ColorAttachment0Ext) // Bind VBO arrays. GL.BindBuffer(ColourArrayBuffer) GL.ColorPointer GL.EnableClientState(ColorArray) GL.BindBuffer(DataArrayBuffer) // If world changed GL.BufferData(DataArrayBuffer) GL.VertexPointer GL.EnableClientState(VertexArray) GL.BindBuffer(ElementArrayBuffer) // Render VBO. GL.DrawElements // Bind visible buffer. GL.Ext.BindFramebuffer(0) GL.DrawBuffer(Back) GL.Clear // Set camera to view texture. GL.BindTexture(ColourTexture) // Render FBO texture GL.Begin(Quads) // Draw texture on quad // TexCoord2/Vertex2 GL.End SwapBuffers }

    Read the article

  • ASP.NET ViewState Tips and Tricks #1

    - by João Angelo
    In User Controls or Custom Controls DO NOT use ViewState to store non public properties. Persisting non public properties in ViewState results in loss of functionality if the Page hosting the controls has ViewState disabled since it can no longer reset values of non public properties on page load. Example: public class ExampleControl : WebControl { private const string PublicViewStateKey = "Example_Public"; private const string NonPublicViewStateKey = "Example_NonPublic"; // DO public int Public { get { object o = this.ViewState[PublicViewStateKey]; if (o == null) return default(int); return (int)o; } set { this.ViewState[PublicViewStateKey] = value; } } // DO NOT private int NonPublic { get { object o = this.ViewState[NonPublicViewStateKey]; if (o == null) return default(int); return (int)o; } set { this.ViewState[NonPublicViewStateKey] = value; } } } // Page with ViewState disabled public partial class ExamplePage : Page { protected override void OnLoad(EventArgs e) { base.OnLoad(e); this.Example.Public = 10; // Restore Public value this.Example.NonPublic = 20; // Compile Error! } }

    Read the article

  • Input string was not in a correct format.

    - by Jon
    I have this error which doesn't happen on my local machine but it does when the code is built by our build sever and deployed to the target server. I can't work out what the problem is, after having spent many hours on this issue. Here is an error trace: [FormatException: Input string was not in a correct format.] System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) +7469351 System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) +119 System.Byte.Parse(String s, NumberStyles style, NumberFormatInfo info) +35 System.String.System.IConvertible.ToByte(IFormatProvider provider) +46 System.Convert.ChangeType(Object value, TypeCode typeCode, IFormatProvider provider) +199 System.Web.UI.WebControls.Parameter.GetValue(Object value, String defaultValue, TypeCode type, Boolean convertEmptyStringToNull, Boolean ignoreNullableTypeChanges) +127 System.Web.UI.WebControls.Parameter.GetValue(Object value, Boolean ignoreNullableTypeChanges) +66 System.Web.UI.WebControls.ParameterCollection.GetValues(HttpContext context, Control control) +285 System.Web.UI.WebControls.SqlDataSourceView.InitializeParameters(DbCommand command, ParameterCollection parameters, IDictionary exclusionList) +251 System.Web.UI.WebControls.SqlDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +476 System.Web.UI.WebControls.SqlDataSource.Select(DataSourceSelectArguments arguments) +19 Customer_NewTenancyList.BindReport(GridSortEventArgs e) +442 Customer_NewTenancyList.Page_Load(Object sender, EventArgs e) +345 System.Web.UI.Control.OnLoad(EventArgs e) +73 baseRslpage.OnLoad(EventArgs e) +16 System.Web.UI.Control.LoadRecursive() +52 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2170 Here is my own trace: Begin PreInit aspx.page End PreInit 3.12888928620816E-05 0.000031 aspx.page Begin Init 7.43111205474439E-05 0.000043 aspx.page End Init 0.00122138428208054 0.001147 aspx.page Begin InitComplete 0.00125379063540199 0.000032 aspx.page End InitComplete 0.00127781603527823 0.000024 aspx.page Begin PreLoad 0.00131022238859967 0.000032 aspx.page End PreLoad 0.00133424778847591 0.000024 aspx.page Begin Load 0.00135575890231859 0.000022 Page_Load 0.00145996209015392 0.000104 BindReport 0.0014856636807192 0.000026 Parameters add start: 30/03/2010 30/04/2010 0.0015569017850034 0.000071 Parameters add ended 0.00160048274291844 0.000044 Trace 1 0.00162450814279468 0.000024 Unhandled Execution Error Input string was not in a correct format. at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) at System.Byte.Parse(String s, NumberStyles style, NumberFormatInfo info) at System.String.System.IConvertible.ToByte(IFormatProvider provider) at System.Convert.ChangeType(Object value, TypeCode typeCode, IFormatProvider provider) at System.Web.UI.WebControls.Parameter.GetValue(Object value, String defaultValue, TypeCode type, Boolean convertEmptyStringToNull, Boolean ignoreNullableTypeChanges) at System.Web.UI.WebControls.Parameter.GetValue(Object value, Boolean ignoreNullableTypeChanges) at System.Web.UI.WebControls.ParameterCollection.GetValues(HttpContext context, Control control) at System.Web.UI.WebControls.SqlDataSourceView.InitializeParameters(DbCommand command, ParameterCollection parameters, IDictionary exclusionList) at System.Web.UI.WebControls.SqlDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) at System.Web.UI.WebControls.SqlDataSource.Select(DataSourceSelectArguments arguments) at Customer_NewTenancyList.BindReport(GridSortEventArgs e) at Customer_NewTenancyList.Page_Load(Object sender, EventArgs e) at System.Web.UI.Control.OnLoad(EventArgs e) at baseRslpage.OnLoad(EventArgs e) at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) And here is my code: Trace.Warn("BindReport") Dim sds As New SqlDataSource sds.SelectCommand = "C_MYSTORED_PROC" sds.ConnectionString = ConfigurationManager.ConnectionStrings("connstring").ConnectionString sds.SelectCommandType = SqlDataSourceCommandType.StoredProcedure Trace.Warn(String.Format("Parameters add start: {0} {1}", dpFrom.Text, dpTo.Text)) sds.SelectParameters.Add(New Parameter("FROMDATE", DbType.DateTime, dpFrom.Text)) sds.SelectParameters.Add(New Parameter("TODATE", DbType.DateTime, dpTo.Text)) Trace.Warn("Parameters add ended") Dim dv As DataView Dim dt As DataTable Trace.Warn("Trace 1") dv = sds.Select(New DataSourceSelectArguments()) Trace.Warn("Trace 2") If e IsNot Nothing Then dv.Sort = String.Format("{0} {1}", e.SortField, e.SortDirection) Trace.Warn("Trace 3") Else gvReport.CurrentSortColumnIndex = 0 gvReport.Columns(0).SortDirection = "DESC" Trace.Warn("Trace 4") End If Trace.Warn("Trace 5") dt = dv.ToTable() Cache("NewTenancyList") = dt Trace.Warn("Trace 6") Trace.Warn("About to databind") gvReport.DataSource = dt gvReport.DataBind() Trace.Warn("Databinded") What I don't understand and this is really weird, why does it work on my local machine but not on the live server? If i build the code on my local machine then copy over the complete \bin directory it works. If I pull the code from source safe, build then copy, I get this error. It seems to choke after the line "dv = sds.Select(New DataSourceSelectArguments())" in the code.

    Read the article

  • Convert flyout menu to respond onclick vs mouseover

    - by Scott B
    The code below creates a nifty flyout menu action on a nested list item sequence. The client has called and wants the change the default behavior in which the flyouts are triggered by mouseover, so that you have to click to trigger a flyout. Ideally, I would just like to modify this code so that you click on a small icon (plus/minus) that sits to the right of the menu item if it has child menus. Can someone give me a bit of guidance on what bits I'd need to change to accomplish this? /* a few sniffs to circumvent known browser bugs */ var sUserAgent = navigator.userAgent.toLowerCase(); var isIE=document.all?true:false; var isNS4=document.layers?true:false; var isOp=(sUserAgent.indexOf('opera')!=-1)?true:false; var isMac=(sUserAgent.indexOf('mac')!=-1)?true:false; var isMoz=(sUserAgent.indexOf('mozilla/5')!=-1&&sUserAgent.indexOf('opera')==-1&&sUserAgent.indexOf('msie')==-1)?true:false; var isNS6=(sUserAgent.indexOf('netscape6')!=-1&&sUserAgent.indexOf('opera')==-1&&sUserAgent.indexOf('msie')==-1)?true:false; var dom=document.getElementById?true:false; /* sets time until menus disappear in milliseconds */ var iMenuTimeout=1500; var aMenus=new Array; var oMenuTimeout; var iMainMenusLength=0; /* the following boolean controls the z-index property if needed */ /* if is only necessary if you have multiple mainMenus in one file that are overlapping */ /* set bSetZIndeces to true (either here or in the HTML) and the main menus will have a z-index set in descending order so that preceding ones can overlap */ /* the integer iStartZIndexAt controls z-index of the first main menu */ var bSetZIndeces=true; var iStartZIndexAt=1000; var aMainMenus=new Array; /* load up the submenus */ function loadMenus(){ if(!dom)return; var aLists=document.getElementsByTagName('ul'); for(var i=0;i<aLists.length;i++){ if(aLists[i].className=='navMenu')aMenus[aMenus.length]=aLists[i]; } var aAnchors=document.getElementsByTagName('a'); var aItems = new Array; for(var i=0;i<aAnchors.length;i++){ // if(aAnchors[i].className=='navItem')aItems[aItems.length] = aAnchors[i]; aItems[aItems.length] = aAnchors[i]; } var sMenuId=null; var oParentMenu=null; var aAllElements=document.body.getElementsByTagName("*"); if(isIE)aAllElements=document.body.all; /* loop through navItem and navMenus and dynamically assign their IDs */ /* each relies on it's parent's ID being set before it */ for(var i=0;i<aAllElements.length;i++){ if(aAllElements[i].className.indexOf('x8menus')!=-1){ /* load up main menus collection */ if(bSetZIndeces)aMainMenus[aMainMenus.length]=aAllElements[i]; } // if(aAllElements[i].className=='navItem'){ if(aAllElements[i].tagName=='A'){ oParentMenu = aAllElements[i].parentNode.parentNode; if(!oParentMenu.childMenus) oParentMenu.childMenus = new Array; oParentMenu.childMenus[oParentMenu.childMenus.length]=aAllElements[i]; if(aAllElements[i].id==''){ if(oParentMenu.className=='x8menus'){ aAllElements[i].id='navItem_'+iMainMenusLength; //alert(aAllElements[i].id); iMainMenusLength++; }else{ aAllElements[i].id=oParentMenu.id.replace('Menu','Item')+'.'+oParentMenu.childMenus.length; } } } else if(aAllElements[i].className=='navMenu'){ oParentItem = aAllElements[i].parentNode.firstChild; aAllElements[i].id = oParentItem.id.replace('Item','Menu'); } } /* dynamically set z-indeces of main menus so they won't underlap */ for(var i=aMainMenus.length-1;i>=0;i--){ aMainMenus[i].style.zIndex=iStartZIndexAt-i; } /* set menu item properties */ for(var i=0;i<aItems.length;i++){ sMenuId=aItems[i].id; sMenuId='navMenu_'+sMenuId.substring(8,sMenuId.lastIndexOf('.')); /* assign event handlers */ /* eval() used here to avoid syntax errors for function literals in Netscape 3 */ eval('aItems[i].onmouseover=function(){modClass(true,this,"activeItem");window.clearTimeout(oMenuTimeout);showMenu("'+sMenuId+'");};'); eval('aItems[i].onmouseout=function(){modClass(false,this,"activeItem");window.clearTimeout(oMenuTimeout);oMenuTimeout=window.setTimeout("hideMenu(\'all\')",iMenuTimeout);}'); eval('aItems[i].onfocus=function(){this.onmouseover();}'); eval('aItems[i].onblur=function(){this.onmouseout();}'); //aItems[i].addEventListener("keydown",function(){keyNav(this,event);},false); } var sCatId=0; var oItem; for(var i=0;i<aMenus.length;i++){ /* assign event handlers */ /* eval() used here to avoid syntax errors for function literals in Netscape 3 */ eval('aMenus[i].onmouseover=function(){window.clearTimeout(oMenuTimeout);}'); eval('aMenus[i].onmouseout=function(){window.clearTimeout(oMenuTimeout);oMenuTimeout=window.setTimeout("hideMenu(\'all\')",iMenuTimeout);}'); sCatId=aMenus[i].id; sCatId=sCatId.substring(8,sCatId.length); oItem=document.getElementById('navItem_'+sCatId); if(oItem){ if(!isOp && !(isMac && isIE) && oItem.parentNode)modClass(true,oItem.parentNode,"hasSubMenu"); else modClass(true,oItem,"hasSubMenu"); /* assign event handlers */ eval('oItem.onmouseover=function(){window.clearTimeout(oMenuTimeout);showMenu("navMenu_'+sCatId+'");}'); eval('oItem.onmouseout=function(){window.clearTimeout(oMenuTimeout);oMenuTimeout=window.clearTimeout(oMenuTimeout);oMenuTimeout=window.setTimeout(\'hideMenu("navMenu_'+sCatId+'")\',iMenuTimeout);}'); eval('oItem.onfocus=function(){window.clearTimeout(oMenuTimeout);showMenu("navMenu_'+sCatId+'");}'); eval('oItem.onblur=function(){window.clearTimeout(oMenuTimeout);oMenuTimeout=window.clearTimeout(oMenuTimeout);oMenuTimeout=window.setTimeout(\'hideMenu("navMenu_'+sCatId+'")\',iMenuTimeout);}'); //oItem.addEventListener("keydown",function(){keyNav(this,event);},false); } } } /* this will append the loadMenus function to any previously assigned window.onload event */ /* if you reassign this onload event, you'll need to include this or execute it after all the menus are loaded */ function newOnload(){ if(typeof previousOnload=='function')previousOnload(); loadMenus(); } var previousOnload; if(window.onload!=null)previousOnload=window.onload; window.onload=newOnload; /* show menu and hide all others except ancestors of the current menu */ function showMenu(sWhich){ var oWhich=document.getElementById(sWhich); if(!oWhich){ hideMenu('all'); return; } var aRootMenus=new Array; aRootMenus[0]=sWhich var sCurrentRoot=sWhich; var bHasParentMenu=false; if(sCurrentRoot.indexOf('.')!=-1){ bHasParentMenu=true; } /* make array of this menu and ancestors so we know which to leave exposed */ /* ex. from ID string "navMenu_12.3.7.4", extracts menu levels ["12.3.7.4", "12.3.7", "12.3", "12"] */ while(bHasParentMenu){ if(sCurrentRoot.indexOf('.')==-1)bHasParentMenu=false; aRootMenus[aRootMenus.length]=sCurrentRoot; sCurrentRoot=sCurrentRoot.substring(0,sCurrentRoot.lastIndexOf('.')); } for(var i=0;i<aMenus.length;i++){ var bIsRoot=false; for(var j=0;j<aRootMenus.length;j++){ var oThisItem=document.getElementById(aMenus[i].id.replace('navMenu_','navItem_')); if(aMenus[i].id==aRootMenus[j])bIsRoot=true; } if(bIsRoot && oThisItem)modClass(true,oThisItem,'hasSubMenuActive'); else modClass(false,oThisItem,'hasSubMenuActive'); if(!bIsRoot && aMenus[i].id!=sWhich)modClass(false,aMenus[i],'showMenu'); } modClass(true,oWhich,'showMenu'); var oItem=document.getElementById(sWhich.replace('navMenu_','navItem_')); if(oItem)modClass(true,oItem,'hasSubMenuActive'); } function hideMenu(sWhich){ if(sWhich=='all'){ /* loop backwards b/c WinIE6 has a bug with hiding display of an element when it's parent is already hidden */ for(var i=aMenus.length-1;i>=0;i--){ var oThisItem=document.getElementById(aMenus[i].id.replace('navMenu_','navItem_')); if(oThisItem)modClass(false,oThisItem,'hasSubMenuActive'); modClass(false,aMenus[i],'showMenu'); } }else{ var oWhich=document.getElementById(sWhich); if(oWhich)modClass(false,oWhich,'showMenu'); var oThisItem=document.getElementById(sWhich.replace('navMenu_','navItem_')); if(oThisItem)modClass(false,oThisItem,'hasSubMenuActive'); } } /* add or remove element className */ function modClass(bAdd,oElement,sClassName){ if(bAdd){/* add class */ if(oElement.className.indexOf(sClassName)==-1)oElement.className+=' '+sClassName; }else{/* remove class */ if(oElement.className.indexOf(sClassName)!=-1){ if(oElement.className.indexOf(' '+sClassName)!=-1)oElement.className=oElement.className.replace(' '+sClassName,''); else oElement.className=oElement.className.replace(sClassName,''); } } return oElement.className; /* return new className */ } //document.body.addEventListener("keydown",function(){keyNav(event);},true); function setBubble(oEvent){ oEvent.bubbles = true; } function keyNav(oElement,oEvent){ alert(oEvent.keyCode); window.status=oEvent.keyCode; return false; }

    Read the article

  • ASP.NET Web Forms Extensibility: Control Adapters

    - by Ricardo Peres
    All ASP.NET controls from version 2.0 can be associated with a control adapter. A control adapter is a class that inherits from ControlAdapter and it has the chance to interact with the control(s) it is targeting so as to change some of its properties or alter its output. I talked about control adapters before and they really a cool feature. The ControlAdapter class exposes virtual methods for some well known lifecycle events, OnInit, OnLoad, OnPreRender and OnUnload that closely match their Control counterparts, but are fired before them. Because the control adapter has a reference to its target Control, it can cast it to its concrete class and do something with it before its lifecycle events are actually fired. The adapter is also notified before the control is rendered (BeginRender), after their children are renderes (RenderChildren) and after itself is rendered (Render): this way the adapter can modify the control’s output. Control adapters may be specified for any class inheriting from Control, including abstract classes, web server controls and even pages. You can, for example, specify a control adapter for the WebControl and UserControl classes, but, curiously, not for Control itself. When specifying a control adapter for a page, it must inherit from PageAdapter instead of ControlAdapter. The adapter for a control, if specified, can be found on the protected Adapter property, and for a page, on the PageAdapter property. The first use of control adapters that came to my attention was for changing the output of standard ASP.NET web controls so that they were more based on CSS and less on HTML tables: it was the CSS Friendly Control Adapters project, now available at http://code.google.com/p/aspnetcontroladapters/. They are interesting because you specify them in one location and they apply anywhere a control of the target type is created. Mind you, it applies to controls declared on markup as well as controls created by code with the new operator. So, how do you use control adapters? The most usual way is through a browser definition file. In it, you specify a set of control adapters and their target controls, for a given browser. This browser definition file is a XML file with extension .Browser, and can either be global (%WINDIR%\Microsoft.NET\Framework64\vXXXX\Config\Browsers) or local to the web application, in which case, it must be placed inside the App_Browsers folder at the root of the web site. It looks like this: 1: <browsers> 2: <browser refID="Default"> 3: <controlAdapters> 4: <adapter controlType="System.Web.UI.WebControls.TextBox" adapterType="MyNamespace.TextBoxAdapter, MyAssembly" /> 5: </controlAdapters> 6: </browser> 7: </browsers> A browser definition file targets a specific browser, so you can have different definitions for Chrome, IE, Firefox, Opera, as well as for specific version of each of those (like IE8, Firefox3). Alternatively, if you set the target to Default, it will apply to all. The reason to pick a specific browser and version might be, for example, in order to circumvent some limitation present in that specific version, so that on markup you don’t need to be concerned with that. Another option is through the the current Browser object of the request: 1: this.Context.Request.Browser.Adapters.Add(typeof(TextBox).FullName, typeof(TextBoxAdapter).FullName); This must go very early on the page lifecycle, for example, on the OnPreInit event, or even on Application_Start. You have to specify the full class name for both the target control and the adapter. Of course, you have to do this for every request, because it won’t be persisted. As an example, you may know that the classic TextBox control renders an HTML input tag if its TextMode is set to SingleLine and a textarea if set to MultiLine. Because the textarea has no notion of maximum length, unlike the input, something must be done in order to enforce this. Here’s a simple suggestion: 1: public class TextBoxControlAdapter : ControlAdapter 2: { 3: protected TextBox Target 4: { 5: get 6: { 7: return (this.Control as TextBox); 8: } 9: } 10:  11: protected override void OnLoad(EventArgs e) 12: { 13: if ((this.Target.MaxLength > 0) && (this.Target.TextMode == TextBoxMode.MultiLine)) 14: { 15: if (this.Target.Page.ClientScript.IsClientScriptBlockRegistered("TextBox_KeyUp") == false) 16: { 17: if (this.Target.Page.ClientScript.IsClientScriptBlockRegistered(this.Target.Page.GetType(), "TextBox_KeyUp") == false) 18: { 19: String script = String.Concat("function TextBox_KeyUp(sender) { if (sender.value.length > ", this.Target.MaxLength, ") { sender.value = sender.value.substr(0, ", this.Target.MaxLength, "); } }\n"); 20:  21: this.Target.Page.ClientScript.RegisterClientScriptBlock(this.Target.Page.GetType(), "TextBox_KeyUp", script, true); 22: } 23:  24: this.Target.Attributes["onkeyup"] = "TextBox_KeyUp(this)"; 25: } 26: } 27: 28: base.OnLoad(e); 29: } 30: } What it does is, for every TextBox control, if it is set for multi line and has a defined maximum length, it injects some JavaScript that will filter out any content that exceeds this maximum length. This will occur for any TextBox that you may have on your site, or any class that inherits from it. You can use any of the previous options to register this adapter. Stay tuned for more ASP.NET Web Forms extensibility tips!

    Read the article

  • Extending a DropDownList control

    - by Andrew Robinson
    I have a rather large application that has literally a hundred DDLs with Yes / No ListItems. In an attempt to same myself some time, I created a Custom Control that extends the standard DDL. It all seems to work fine but I am having some issues when assigning the SelectedValue property in code where the selected value does not seem to have an affect on the control. I wonder if I should be adding my items during Init or PagePreLoad? Should I be calling base.OnInit before or after I add the list items? This mostly works but not 100%. (v3.5) public class YesNoDropDownList : DropDownList { protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (!Page.IsPostBack) { base.Items.Add(new ListItem("Yes", "YES")); base.Items.Add(new ListItem("No", "NO")); } } }

    Read the article

  • Setting a session variable in Global.asax causes AJAX errors

    - by Fly_Trap
    I'm getting a very peculiar problem with my asp.net application, it took me an age to track down but I still don't know what is causing this behaviour. If I set a session variable in the Application_PreRequestHandlerExecute event, then my external JavaScript files are ignored, and therfore causing a raft of errors. I have simplified the problem below. E.g. I have file called JScript.js containing the code: function myAlert() { alert("Hi World"); } And in my Default.aspx file I reference the js with the code: <script src="JScript.js" type="text/javascript"></script> And in the body onload event I call the myAlert() function: <body onload="myAlert()"> And finally in the Global.asax file: Private Sub Application_PreRequestHandlerExecute(ByVal sender As Object, ByVal e As EventArgs) HttpContext.Current.Session("myVar") = "MyValue" End Sub If you run the Default.aspx file you will see the js function isnt called, however, if you comment out the line of code Global.asax then the external js is called and the function executed when the page loads. Why is this?

    Read the article

  • Javascript - how to change elements content inside a page when using iframes, using dom, not jquery

    - by Erez
    Hello all, I have this iframe and as u can see it call a js function with the onload trigger. <iframe name="top" id="top" width="99%" height="20%" src="top.htm" frameborder="0" scrolling="no" onload="log_in()"></iframe> What i need to do is to effect the element inside "top.htm" (change innerHTML and stuff like that) from that function. But the problem is that the funnction does not recognize the elements of the "top.htm" page, only the ones in index.htm (the page with the iframes). p.s. i have to use DOM and i have to use iframes. Any one knows how to do that? 10x :-)

    Read the article

  • Pass variable to Google Custom Search Engine

    - by Matt
    Is it possible to pass a search variable into the Google Custom Search Engine that I have embedded on my website? I can get the search engine to work, but I can't pass it a term via POST (it's coming from a search button on other pages of the website) I tried to hack the code I found here: http://code.google.com/apis/ajax/playground/?exp=search#hello_world And this is what I have so far... ($q is the term I am passing to it) <script type="text/javascript"> google.load('search', '1', {language : 'en'}); function OnLoad() { var customSearchControl = new google.search.CustomSearchControl('***my key****'); customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET); customSearchControl.draw('cse'); searchControl.execute("$q"); } google.setOnLoadCallback(OnLoad); </script> Thanks

    Read the article

  • Why won't this Jquery run on IE?

    - by Charles Marsh
    Hello All, I have this Jquery code (function($){ $.expr[':'].linkingToImage = function(elem, index, match){ // This will return true if the specified attribute contains a valid link to an image: return !! ($(elem).attr(match[3]) && $(elem).attr(match[3]).match(/\.(gif|jpe?g|png|bmp)$/i)); }; $.fn.imgPreview = function(userDefinedSettings){ var s = $.extend({ /* DEFAULTS */ // CSS to be applied to image: imgCSS: {}, // Distance between cursor and preview: distanceFromCursor: {top:2, left:2}, // Boolean, whether or not to preload images: preloadImages: true, // Callback: run when link is hovered: container is shown: onShow: function(){}, // Callback: container is hidden: onHide: function(){}, // Callback: Run when image within container has loaded: onLoad: function(){}, // ID to give to container (for CSS styling): containerID: 'imgPreviewContainer', // Class to be given to container while image is loading: containerLoadingClass: 'loading', // Prefix (if using thumbnails), e.g. 'thumb_' thumbPrefix: '', // Where to retrieve the image from: srcAttr: 'rel' }, userDefinedSettings), $container = $('<div/>').attr('id', s.containerID) .append('<img/>').hide() .css('position','absolute') .appendTo('body'), $img = $('img', $container).css(s.imgCSS), // Get all valid elements (linking to images / ATTR with image link): $collection = this.filter(':linkingToImage(' + s.srcAttr + ')'); // Re-usable means to add prefix (from setting): function addPrefix(src) { return src.replace(/(\/?)([^\/]+)$/,'$1' + s.thumbPrefix + '$2'); } if (s.preloadImages) { (function(i){ var tempIMG = new Image(), callee = arguments.callee; tempIMG.src = addPrefix($($collection[i]).attr(s.srcAttr)); tempIMG.onload = function(){ $collection[i + 1] && callee(i + 1); }; })(0); } $collection .mousemove(function(e){ $container.css({ top: e.pageY + s.distanceFromCursor.top + 'px', left: e.pageX + s.distanceFromCursor.left + 'px' }); }) .hover(function(){ var link = this; $container .addClass(s.containerLoadingClass) .show(); $img .load(function(){ $container.removeClass(s.containerLoadingClass); $img.show(); s.onLoad.call($img[0], link); }) .attr( 'src' , addPrefix($(link).attr(s.srcAttr)) ); s.onShow.call($container[0], link); }, function(){ $container.hide(); $img.unbind('load').attr('src','').hide(); s.onHide.call($container[0], this); }); // Return full selection, not $collection! return this; }; })(jQuery); It works perfectly in all browsers apart from IE, which it does nothing, no errors, no clues? I have a funny feeling IE doesn't support attr? Can anyone offer any advice?

    Read the article

  • javascript on twitter to prevent embedding the html page.

    - by Reginald
    This is the javascript that you can find in www.twitter.com (just click to see the source code) I have just reformatted it for clarity: if (window.top !== window.self) { document.write = ""; window.top.location = window.self.location; setTimeout(function() { document.body.innerHTML = ''; }, 1); window.self.onload = function(evt) { document.body.innerHTML = ''; }; } now I understand this trick is to prevent other sites to wrap twitter in other iframes. but what I want to ask is do we really need all of this code ? what's the need of setting a function to execute in 1 millisecond, one to execute at 'onload' and one now. is that paranoia or is it really worth ? Many THanks in advance Reg

    Read the article

  • Question regarding common class

    - by Rocky Singh
    I have following two classes: public class A : System.Web.UI.WebControls.Button { public virtual string X { get { object obj = ViewState["X"]; if (obj != null) return (string)obj; return null; } set { ViewState["X"] = value; } } protected override void OnLoad(EventArgs e) { X=2; } } and public class B : System.Web.UI.WebControls.TextBox { public virtual string X { get { object obj = ViewState["X"]; if (obj != null) return (string)obj; return null; } set { ViewState["X"] = value; } } protected override void OnLoad(EventArgs e) { X=2; } } As you must be seeing the class A and B have exactly the same code , my question is how can I make a common class for it and use these two classes.

    Read the article

  • How to run Javascript code before document is completely loaded (using jQuery)

    - by eliza sahoo
    Hi all, I am sahring atip with you all.Please add on to this discussion. JQuery helps faster page load than javascript. JQuery functions are fired when the related elements are loaded, instead of complete pageload. This is a common practice to call a javascript function when page is loaded like window.onload = function(){ alert("Mindfire") } or Inside of which is the code that we want to run right when the page is loaded. Problematically, however, the Javascript code isn't run until all images are finished downloading (this includes banner ads). The reason for using window.onload in the first place is due to the fact that the HTML 'document' isn't finished loading yet, when you first try to run your code. To circumvent both problems, jQuery has a simple statement that checks the document and waits until it's ready to be manipulated, known as the ready event $(document).ready(function() { // Your code here });

    Read the article

  • Just a small problem regarding javscript BOM question

    - by caramel1991
    The question is this: Create a page with a number of links. Then write code that fires on the window onload event, displaying the href of each of the links on the page. And this is my solution <html> <body language="Javascript" onload="displayLink()"> <a href="http://www.google.com/">First link</a> <a href="http://www.yahoo.com/">Second link</a> <a href="http://www.msn.com/">Third link</a> <script type="text/javascript" language="Javascript"> function displayLink() { for(var i = 0;document.links[i];i++) { alert(document.links[i].href); } } </script> </body> </html> This is the answer provided by the book <html> <head> <script language=”JavaScript” type=”text/javascript”> function displayLinks() { var linksCounter; for (linksCounter = 0; linksCounter < document.links.length; linksCounter++) { alert(document.links[linksCounter].href); } } </script> </head> <body onload=”displayLinks()”> <A href=”link0.htm” >Link 0</A> <A href=”link1.htm”>Link 2</A> <A href=”link2.htm”>Link 2</A> </body> </html> Before I get into the javascript tutorial on how to check user browser version or model,I was using the same method as the example,by acessing the length property of the links array for the loop,but after I read through the tutorial,I find out that I can also use this alternative ways,by using the method that the test condition will evalute to true only if the document.links[i] return a valid value,so does my code is written using the valid method??If it's not,any comment regarding how to write a better code??Correct me if I'm wrong,I heard some of the people say "a good code is not evaluate solely on whether it works or not,but in terms of speed,the ability to comprehend the code,and could posssibly let others to understand the code easily".Is is true??

    Read the article

  • Post Loading ads from Google Admanager

    - by Prem
    I have changed code around to basically load an add the bottom of the page in a hidden div and attached an onload event handler that called document.getElementById(xxx).appendChild() to take the hidden ad and move it into the right spot in my page. This works GREAT.. however when the ad is a text ad it AFTER i move the ad there is nothing in the rendered Iframe. I did tests to see what it looks like before i move it and sure enough the text links load in the IFRAME but the second i do the appendChild call to move the div that contains the ad i seem to loose the contents of the Iframe. Any ideas whats going on <div id="myad" style="display: none;"> GA_googleFillSlot("MyADSlotName"); </div> <script> window.onload = function() { // leader board document.getElementById('adplaceholder').appendChild(document.getElementById('myAd')); document.getElementById('myAd').style.display = ''; </script

    Read the article

  • Disable page redirects using Greasemonkey

    - by Tomer Cohen
    A website I wish to tweak is using window.location in order to redirect specific users to a blocking page. That website is doing it in plain <script> tag, so it is impossible to bypass it by overriding the onload event using document.body.setAttribute('onload','');. Is there another way to inject my code to the page without using Firefox extensions such as NoScript? <!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> <title></title> <script type="text/javascript"> if (1) window.location="http://example.net" </script> </head> <body></body> </html>

    Read the article

  • Iframe auto-height not working when page changes in IE

    - by DisgruntledGoat
    I have an iframe in a page, with the following auto-height script. function autoHeight(e) { if ( e.contentDocument ) { e.height = e.contentDocument.body.offsetHeight + 35; } else { e.height = e.contentWindow.document.body.scrollHeight + 35; } } document.domain = "totalstudents.co.uk"; var ifr = document.getElementById('housingdata'); ifr.onload = function() { autoHeight(ifr); } The iframe resizes fine when the outer page is loaded, but when I go to a new page in the iframe, scrollbars appear and the page does not get resized in Internet Explorer. In other browsers the iframe gets resized, because the onload event fires each time. I'm using IE8 but the outer page is setting it to IE7 compatibility mode. Is there a workaround for IE?

    Read the article

  • Nested Execution Flow Control

    - by chris
    I've read tens of answers related to callbacks, promises and other ways to control flow, but I can't still wrap my head around this task, obviously due to my lack of competence. I have a nested problem: In test_1() (and the other functions) I would like to ensure that the rows are added to the table according to the order in which the elements are in the object; I would like to execute either test_2 or test_3 (or both after each other) only after test_1 has finished completely. Actually the right sequence will only be known at runtime (there will be a switch with the possible sequences, like 1,2,3 or 1,3,2 or 1,2,1,3 or 1,3,3,2, etc...) Code: $(function () { // create table tbl = document.createElement('table'); tbl.className = "mainTbl"; $("body").append(tbl); }); function test_1() { $.each(obj, function () { var img = new Image(); img.onload = function () { // add row of data to table var row = tbl.insertRow(-1); var c1 = row.insertCell(0); c1.innerHTML = "loaded"; }; img.onerror = function () { // add row of data to table var row = tbl.insertRow(-1); var c1 = row.insertCell(0); c1.innerHTML = "not loaded"; }; img.src = this.url; }); } function test_2() { $.each(obj, function () { var img = new Image(); img.onload = function () { // add row of data to table var row = tbl.insertRow(-1); var c1 = row.insertCell(0); c1.innerHTML = "loaded"; }; img.onerror = function () { // add row of data to table var row = tbl.insertRow(-1); var c1 = row.insertCell(0); c1.innerHTML = "not loaded"; }; img.src = this.url; }); } function test_3() { $.each(obj, function () { var img = new Image(); img.onload = function () { // add row of data to table var row = tbl.insertRow(-1); var c1 = row.insertCell(0); c1.innerHTML = "loaded"; }; img.onerror = function () { // add row of data to table var row = tbl.insertRow(-1); var c1 = row.insertCell(0); c1.innerHTML = "not loaded"; }; img.src = this.url; }); } I know that calling the functions in sequence doesn't work as they don't wait for each other... I think promises are they way to go but I can't find the right combination and the documentation is way too complex for my skills. What's the best way to structure the code so that it's executed in the right order?

    Read the article

  • How to handle HTML rendering in C# WebBrowser control?

    - by sashaeve
    Is any way to handle a moment when HTML page is rendered on C# WebBrowser control? Edit. WebBrowser control has many events such as Navigated, GotFocus etc. I need to handle an event when HTML is rendered inside the control. Just wondered is it possible. For example, in asp.net we have OnRender, OnInit, OnLoad, OnPreLoad events which form web-page life-cycle. OnLoad in asp.net is something like Navigated for WebBrowser, the idea is to handle event similar to OnRender.

    Read the article

  • jQuery AJAX loaded content slideshow

    - by user369437
    Hi I have created a slideshow to go on a zencart site. The slidehow page is an external file that is loaded via AJAX. Please find the code snippet below. jQuery(document).ready(function() { //Load the slideshow page jQuery("#slidershow").load("/xxxxxxxxxx/index.php?main_page=page&id=2 #slider"); //Targetting live content, #slider is loaded via AJAX jQuery("#slider").live("click" ,function(){jQuery(this).s3Slider({timeOut:5000});}); }); Instead of live("click"...) I would like it to appear onload automatically.. But live() does not support "load". What other ways I could get the plugin to trigger onload? hope the question is clear.

    Read the article

  • How to ensure images all loaded before I reference in my HTML canvas [closed]

    - by mark stephens
    I want to draw some images in on a HTML canvas with context.drawImage(Im1 ,205,18,184,38); In order to make sure it loads I need to put in code like this but then I cannot draw things with it var Im1 = new Image(); Im1.src="rechnung11014page1/img/1/Im1.png"; Im1.onload = function() { context.drawImage(Im1 ,205,18,184,38); } Is there a way to load all the images and then execute a block of code using several images?

    Read the article

  • Repeat a part of spritesheet as background

    - by Moiblpadde
    So I'm trying to repeat a part of my spritesheet as a background (js, canvas). My code so far: var canvas = $("#board")[0], ctx = canvas.getContext("2d"), sprite = new Image(); sprite.src = "spritesheet.png"; sprite.onload = function(){ ctx.fillStyle = ctx.createPattern(spriteBg, "repeat"); ctx.fillRect(0, 25, 500, 500); } This is fine, but as you can see, it repeat the whole sprite, not just a part of it, and I just can't figure out how to do it D:

    Read the article

  • Issue with Sharepoint 2010 application page

    - by Matt Moriarty
    I am relatively new to Sharepoint and am using version 2010. I am having a problem with the following code in an application page I am trying to build: using System; using Microsoft.SharePoint; using Microsoft.SharePoint.WebControls; using System.Text; using Microsoft.SharePoint.Administration; using Microsoft.Office.Server; using Microsoft.Office.Server.UserProfiles; using Microsoft.SharePoint.Utilities; namespace SharePointProject5.Layouts.SharePointProject5 { public partial class ApplicationPage1 : LayoutsPageBase { protected void Page_Load(object sender, EventArgs e) { SPContext context = SPContext.Current; StringBuilder output = new StringBuilder(); using(SPSite site = context.Site) using (SPWeb web = site.AllWebs["BDC_SQL"]) { UserProfileManager upmanager = new UserProfileManager(ServerContext.GetContext(site)); string ListMgr = ""; string ADMgr = ""; bool allowUpdates = web.AllowUnsafeUpdates; web.AllowUnsafeUpdates = true; web.Update(); SPListCollection listcollection = web.Lists; SPList list = listcollection["BDC_SQL"]; foreach (SPListItem item in list.Items) { output.AppendFormat("<br>From List - Name & manager: {0} , {1}", item["ADName"], item["Manager_ADName"]); UserProfile uProfile = upmanager.GetUserProfile(item["ADName"].ToString()); output.AppendFormat("<br>From Prof - Name & manager: {0} , {1}", uProfile[PropertyConstants.DistinguishedName], uProfile[PropertyConstants.Manager]); ListMgr = item["Manager_ADName"].ToString(); ADMgr = Convert.ToString(uProfile[PropertyConstants.Manager]); if (ListMgr != ADMgr) { output.AppendFormat("<br>This record requires updating from {0} to {1}", uProfile[PropertyConstants.Manager], item["Manager_ADName"]); uProfile[PropertyConstants.Manager].Value = ListMgr; uProfile.Commit(); output.AppendFormat("<br>This record has had its manager updated"); } else { output.AppendFormat("<br>This record does not need to be updated"); } } web.AllowUnsafeUpdates = allowUpdates; web.Update(); } Label1.Text = output.ToString(); } } } Everything worked fine up until I added in the 'uProfile.Commit();' line. Now I am getting the following error message: Microsoft.SharePoint.SPException was unhandled by user code Message=Updates are currently disallowed on GET requests. To allow updates on a GET, set the 'AllowUnsafeUpdates' property on SPWeb. Source=Microsoft.SharePoint ErrorCode=-2130243945 NativeErrorMessage=FAILED hr detected (hr = 0x80004005) NativeStackTrace="" StackTrace: at Microsoft.SharePoint.SPGlobal.HandleComException(COMException comEx) at Microsoft.SharePoint.Library.SPRequest.ValidateFormDigest(String bstrUrl, String bstrListName) at Microsoft.SharePoint.SPWeb.ValidateFormDigest() at Microsoft.Office.Server.UserProfiles.UserProfile.UpdateBlobProfile() at Microsoft.Office.Server.UserProfiles.UserProfile.Commit() at SharePointProject5.Layouts.SharePointProject5.ApplicationPage1.Page_Load(Object sender, EventArgs e) at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) at System.Web.UI.Control.OnLoad(EventArgs e) at Microsoft.SharePoint.WebControls.UnsecuredLayoutsPageBase.OnLoad(EventArgs e) at Microsoft.SharePoint.WebControls.LayoutsPageBase.OnLoad(EventArgs e) at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) InnerException: System.Runtime.InteropServices.COMException Message=<nativehr>0x80004005</nativehr><nativestack></nativestack>Updates are currently disallowed on GET requests. To allow updates on a GET, set the 'AllowUnsafeUpdates' property on SPWeb. Source="" ErrorCode=-2130243945 StackTrace: at Microsoft.SharePoint.Library.SPRequestInternalClass.ValidateFormDigest(String bstrUrl, String bstrListName) at Microsoft.SharePoint.Library.SPRequest.ValidateFormDigest(String bstrUrl, String bstrListName) InnerException: I have tried to rectify this by adding in code to allow the unsafe updates but I still get this error. Does anyone have any guidance for me? It would be much appreciated. Thanks in advance, Matt.

    Read the article

  • Geolocation through Android's GPS Provider on a website?

    - by Corey Ogburn
    I'm trying to get the geolocation of the mobile device in a regular website, not a webview of an application or anything native like that. I'm getting a location, but it's highly inaccurate, the accuracy comes back as 3230 or some other outrageous number. I'm assuming that's in meters, either way it's not nearly accurate enough. By comparison, the same webpage on a laptop gets an accuracy of 30-40. My first thought was that it was using the Network Provider instead of the GPS Provider, telling me where I am based on tower location and reach. A little research later I found enableHighAccuracy and set it true in the options that I pass. After including that, I still notice no difference. Here's the test page's HTML/javascript: <html> <head> <script type="text/javascript" src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0"></script> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js"></script> <script type="text/javascript"> function OnLoad() { $("#Status").text("Init"); if (navigator.geolocation) { $("#Status").text("Supports Geolocation"); navigator.geolocation.getCurrentPosition(HandleLocation, LocationError, { enableHighAccuracy: true }); $("#Status").text("Sent position request..."); } else { $("#Status").text("Doesn't support geolocation"); } } function HandleLocation(position) { $("#Status").text("Received response:"); $("#Position").text("(" + position.coords.latitude + ", " + position.coords.longitude + ") accuracy: " + position.coords.accuracy); var loc = new Microsoft.Maps.Location(position.coords.latitude, position.coords.longitude); GetMap(loc); } function LocationError(error) { switch(error.code) { case error.PERMISSION_DENIED: alert("Location not provided"); break; case error.POSITION_UNAVAILABLE: alert("Current location not available"); break; case error.TIMEOUT: alert("Timeout"); break; default: alert("unknown error"); break; } } function GetMap(loc) { var map = new Microsoft.Maps.Map(document.getElementById("mapDiv"), {credentials: "Aj59meaCR1e7rNgkfQy7j08Pd3mzfP1r04hGesGmLe2a3ZwZ3iGecwPX2SNPWq5a", center: loc, mapTypeId: Microsoft.Maps.MapTypeId.road, zoom: 15}); } </script> </head> <body onload="javascript:OnLoad()"> <div id="Status"></div> <div id="Position"></div><br/> <div id='mapDiv' style="position:relative; width:600px; height:400px;"></div> </body> </html> I'm testing this on a rooted MyTouch 3G running Cyanogen 6.1 stable, Android 2.2 and GPS is enabled. In case rooting was a problem, I have also had various friends and coworkers try the webpage on their non-rooted 2.0+ Android devices. Each phone had various effects on the accuracy, but none were better than 1000, I attribute this to the different carriers. I have not (but eventually will) tested with iPhone or other location-aware cell phones.

    Read the article

< Previous Page | 3 4 5 6 7 8 9 10 11 12 13 14  | Next Page >