Search Results

Search found 4 results on 1 pages for 'zarigani'.

Page 1/1 | 1 

  • jQuery AutoComplete select firing after change?

    - by Zarigani
    I'm using the jQuery UI AutoComplete control (just updated to jQuery UI 1.8.1). Whenever the user leaves the text box, I want to set the contents of the text box to a known-good value and set a hidden ID field for the value that was selected. Additionally, I want the page to post back when the contents of the text box are changed. Currently, I am implementing this by having the autocomplete select event set the hidden id and then a change event on the text box which sets the textbox value and, if necessary, causes a post back. If the user just uses the keyboard, this works perfectly. You can type, use the up and down arrows to select a value and then tab to exit. The select event fires, the id is set and then the change event fires and the page posts back. If the user starts typing and then uses the mouse to pick from the autocomplete options though, the change event fires (as focus shifts to the autocomplete menu?) and the page posts back before the select event has a chance to set the ID. Is there a way to get the change event to not fire until after the select event, even when a mouse is used? $(function() { var txtAutoComp_cache = {}; var txtAutoComp_current = { label: $('#txtAutoComp').val(), id: $('#hiddenAutoComp_ID').val() }; $('#txtAutoComp').change(function() { if (this.value == '') { txtAutoComp_current = null; } if (txtAutoComp_current) { this.value = txtAutoComp_current.label ? txtAutoComp_current.label : txtAutoComp_current; $('#hiddenAutoComp_ID').val(txtAutoComp_current.id ? txtAutoComp_current.id : txtAutoComp_current); } else { this.value = ''; $('#hiddenAutoComp_ID').val(''); } // Postback goes here }); $('#txtAutoComp').autocomplete({ source: function(request, response) { var jsonReq = '{ "prefixText": "' + request.term.replace('\\', '\\\\').replace('"', '\\"') + '", "count": 0 }'; if (txtAutoComp_cache.req == jsonReq && txtAutoComp_cache.content) { response(txtAutoComp_cache.content); return; } $.ajax({ url: 'ajaxLookup.asmx/CatLookup', contentType: 'application/json; charset=utf-8', dataType: 'json', data: jsonReq, type: 'POST', success: function(data) { txtAutoComp_cache.req = jsonReq; txtAutoComp_cache.content = data.d; response(data.d); if (data.d && data.d[0]) { txtAutoComp_current = data.d[0]; } } }); }, select: function(event, ui) { if (ui.item) { txtAutoComp_current = ui.item; } $('#hiddenAutoComp_ID').val(ui.item ? ui.item.id : ''); } }); });

    Read the article

  • Clearing Session in Global Application_Error

    - by Zarigani
    Whenever an unhandled exception occurs on our site, I want to: Send a notification email Clear the user's session Send the user to a error page ("Sorry, a problem occurred...") The first and last I've had working for a long time but the second is causing me some issues. My Global.asax.vb includes: Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs) ' Send exception report Dim ex As System.Exception = Nothing If HttpContext.Current IsNot Nothing AndAlso HttpContext.Current.Server IsNot Nothing Then ex = HttpContext.Current.Server.GetLastError End If Dim eh As New ErrorHandling(ex) eh.SendError() ' Clear session If HttpContext.Current IsNot Nothing AndAlso HttpContext.Current.Session IsNot Nothing Then HttpContext.Current.Session.Clear() End If ' User will now be sent to the 500 error page (by the CustomError setting in web.config) End Sub When I run a debug, I can see the session being cleared, but then on the next page the session is back again! I eventually found a reference that suggests that changes to session will not be saved unless Server.ClearError is called. Unfortunately, if I add this (just below the line that sets "ex") then the CustomErrors redirect doesn't seem to kick in and I'm left with a blank page? Is there a way around this?

    Read the article

  • Adding to page control collection from inside a user control

    - by Zarigani
    I have an asp.net usercontrol which represents a "popup" dialog. Basically, it's a wrapper for the jQuery UI dialog which can be subclassed to easily make dialogs. As part of this control, I need to inject a div into the page the control is used on, either at the very top or very bottom of the form so that when the popup is instantiated, it's parent is changed to this div. This allows "nested" popups without the child popup being trapped inside the parent popup. The trouble is, I can't find a safe way to inject this div into the page. A usercontrol doesn't have a preinit event, so I can't do it there, and calling Page.Form.Controls.Add(...) in Init, Load or PreRender causes the standard exception "The control collection cannot be modified during DataBind, Init, Load, PreRender or Unload phases." I thought I had found a solution by using... ScriptManager.RegisterClientScriptBlock(Page, Me.GetType, UniqueID + "_Dialog_Div", containerDiv, False) ... which seemed to work well normally, but recently a coworker tried putting an UpdatePanel inside the dialog and now she's getting the error "The script tag registered for type 'ASP.controls_order_viewzips_ascx' and key 'ctl00$ContentBody$OViewZips_Dialog_Div' has invalid characters outside of the script tags: . Only properly formatted script tags can be registered." How are you supposed to add controls to the pages control collection from inside a user control?

    Read the article

  • Using generics in dotnet for functions with any number of arguments?

    - by Zarigani
    I would like to have a function that can "wrap" any other function call. In this particular case, it would allow me to write some more generic transaction handling around some specific operations. I can write this for any particular number of arguments, e.g. for one argument: Public Shared Sub WrapFunc(Of T)(ByVal f As Action(Of T), ByVal arg As T) ' Test some stuff, start transaction f(arg) ' Test some stuff, end transaction End Sub ... but I was hoping to have this handle any number of arguments without having to have duplicate code for 0 args, 1 arg, 2 args, etc. Is there a way of doing this?

    Read the article

1