Showing posts with label events. Show all posts
Showing posts with label events. Show all posts

Monday, March 26, 2012

Certain events not firing on server (but they are in dev)

I have a small web app that uses an update panel. Its asyncpostback event fires and updates a session variable. In the process, the pageload event fires and repopulates the elements within my update panel. This works in my dev environment, but doesn't work when I publish the site to my website.

The session variable is updated like it should via asyncpostback, but the pageload event isn't fired. Thus my chart within the updatepanel isn't redrawn. I have ajax installed on the server and the appropriate dll's are in the bin folder.

Any idea why this is happening?

The only thing I can think of is there are differences in your web.config file.


The web.config goes along with the publish (I've even manually copied the file over)


hello.

that is strange because the load event will always fire during a postback. have you tried hosting the app in IIS in your development environment?


Yeah I knew the web.config file went though with the Publish, but I wans't sure if you were using the Publish option in Visual Studio or if you were manually publishing it by copying the dll and aspx files. I had a few ideas as to what might be causing the problem but I keep throwing those ideas out because it is working in your test environment. At this point, I can only take guesses. I dont think AJAX.net is the problem because your session is getting updated aysnc. Since all the code is the same in both environments, that ww know of, I would next try to figure out what is different. Are the dll files different in any way, specifically the ajax dll's. Also try manually deploying the site. I have had some publshing problems with Visual Studio 2005 when publishing to ftp (The host I was using had users experieincing problems with the publish not publishing correctly.) Although the problem I and my host had was more to deal with Visual Studio stopming over some security permssions.. dont ask me how, it just did.


I have manually copied the files to the server as well (it is sitting right next to my desktop on the same domain).


hum...well, not sure on the response your chart is returning from the server. there shoudln't be any problems with it since you're seeing it work on the dev machine. anyway, how about using fiddler to see the response returned from the server ?


fiddler.. hmmm... thats a new one on me. I'll check it out.


it's an http proxy. really good to see the contents sent to and from the browser:

http://www.fiddlertool.com/


It is weird, Have you fixed it?


No, not yet. It's strange that the async call works but the page load isn't firing.

Catputing events in UpdatePanels

All,

Hopefully someone here will have an answer for something that's driving me crazy at the moment...

I have a control on a page that is within an update panel. The control has to be within the update panel as we need to change the control without a full page refresh.

All works well except a series of post backs that are generated that should perform some processing then redirect the user to a new page. As is logical this doesn't work as it's not the browser that is generating the postbacks but soem JavaScript in the page.

What I need to know is: Is it possible to tell the update panel to ognore events created by these controls? Or am I going to have find a different way around this problem?

TIA

Stu

Opps... Do I feel dum... Turns out it works just fine, I just assumed that the person who prototyped the page had wired up all the event handers, in fact he'd only wired up half. The reason the click did nothing was because there was no handler there to do anything...Embarrassed

Catching key press events. For example username control without postback

Hi atlas developers and implementers,

For example I have a textbox and I want that on every key press the written string will be controlled from database and it should say whether it is found on database or not. I'm using atlas 2.0. It is like username control without postback.

How can I do this..

Kind Regards,

Fatih U?AR.
Postglobal Ltd.
R&D ManagerHi,

basic example + bonus behavior:

<%@. Page Language="C#" %><%@. Import Namespace="System.Data" %><%@. Import Namespace="System.Web.Services" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server"> private DataTable data = null; protected void Page_Load(object sender, EventArgs e) { BuildData(); } private void BuildData() { data = new DataTable(); data.Columns.Add(new DataColumn("Username", typeof(string))); data.Rows.Add("garbin"); data.Rows.Add("leoscorpio82"); } [WebMethod] public bool CheckForUsername(string username) { bool userExists = data.Select("Username = '" + username + "'").Length > 0; return userExists; }</script><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"> <title>Untitled Page</title></head><body> <form id="form1" runat="server"> <atlas:ScriptManager ID="sm" runat="server"></atlas:ScriptManager> <div> <span>Username:</span> <asp:TextBox ID="txtUsername" runat="server"></asp:TextBox> </div> </form> <script type="text/javascript"> function txtUsername_Keypress(sender, e) { PageMethods.CheckForUsername($object('txtUsername').get_text(), onCheckComplete); } function onCheckComplete(result) { $object('txtUsername').get_style().backgroundColor = (result) ? '#ffffff' : '#ff0000'; } </script> <script type="text/xml-script"> <page> <components> <textBox id="txtUsername"> <behaviors> <keyUpBehavior keyup="txtUsername_Keypress" /> </behaviors> </textBox> </components> </page> </script> <script type="text/javascript"> // A behavior to handle the keyup event. Type.registerNamespace('AtlasExamples'); AtlasExamples.KeyUpBehavior = function() { AtlasExamples.KeyUpBehavior.initializeBase(this); // Private members. var _keyupHandler; // Events. this.keyup = this.createEvent(); // Initialize / Dispose. this.initialize = function() { AtlasExamples.KeyUpBehavior.callBaseMethod(this, 'initialize'); _keyupHandler = Function.createDelegate(this, keyupHandler); this.control.element.attachEvent('onkeyup', _keyupHandler); } this.dispose = function() { this.control.element.detachEvent('onkeyup', _keyupHandler); _keyupHandler = null; AtlasExamples.KeyUpBehavior.callBaseMethod(this, 'dispose'); } // Descriptor. this.getDescriptor = function() { var td = AtlasExamples.KeyUpBehavior.callBaseMethod(this, 'getDescriptor'); td.addEvent('keyup', true); return td; } // Event Handler. function keyupHandler() { //debug.trace(event.keyCode); this.keyup.invoke(this, Sys.EventArgs.Empty); } } AtlasExamples.KeyUpBehavior.registerClass('AtlasExamples.KeyUpBehavior', Sys.UI.Behavior); Sys.TypeDescriptor.addType('script', 'keyUpBehavior', AtlasExamples.KeyUpBehavior); </script></body></html>

hello ,

the answer is ok but where is the 'AtlasExamples' behavior

i'll be glad for you answer

kind regards,


Hi,

AtlasExamples is a namespace (defined with a call to Type.registerNamespace at the beginning of the Javascript code) while the behavior is the AtlasExamples.KeyUpBehavior class defined inside the Javascript code block (it inherits from the base Sys.UI.Behavior class).


hi garbin yes i know but i don't have the dll file of the namespace. so i can't get it work. I need necessary files.. I'll be glad if you send me the files tofatihu@.postglobal.com

regards,


Hi,

sorry, but what do you mean by "the dll of the namespace"?


I mean, I run the code you wrote but it didn't work, what should I do, it didn't validate

Hi,

ah, sorry, didn't notice that the code was written for CTPs :)

Here's the updated code:

<%@. Page Language="C#" %><%@. Import Namespace="System.Data" %><%@. Import Namespace="System.Web.Services" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server"> private static DataTable data = null; protected void Page_Load(object sender, EventArgs e) { BuildData(); } private void BuildData() { data = new DataTable(); data.Columns.Add(new DataColumn("Username", typeof(string))); data.Rows.Add("garbin"); data.Rows.Add("leoscorpio82"); } [WebMethod] public static bool CheckForUsername(string username) { bool userExists = data.Select("Username = '" + username + "'").Length > 0; return userExists; }</script><html xmlns="http://www.w3.org/1999/xhtml" ><head id="Head1" runat="server"> <title>Untitled Page</title></head><body> <form id="form1" runat="server"> <asp:ScriptManager ID="TheScriptManager" runat="server"> <Scripts> <asp:ScriptReference Assembly="Microsoft.Web.Preview" Name="PreviewScript.js" /> </Scripts> </asp:ScriptManager> <div> <span>Username:</span> <asp:TextBox ID="txtUsername" runat="server"></asp:TextBox> </div> </form> <script type="text/javascript"><!-- function txtUsername_Keypress(sender, e) { PageMethods.CheckForUsername($get('txtUsername').value, onCheckComplete); } function onCheckComplete(result) { $get('txtUsername').style.backgroundColor = (result) ? '#ffffff' : '#ff0000'; } //--> </script> <script type="text/xml-script"> <page xmlns="http://schemas.microsoft.com/xml-script/2005" xmlns:cc="AtlasExamples"> <components> <textBox id="txtUsername"> <behaviors> <cc:keyUpBehavior keyUp="txtUsername_Keypress" /> </behaviors> </textBox> </components> </page> </script> <script type="text/javascript"> // A behavior to handle the keyup event. Type.registerNamespace('AtlasExamples'); AtlasExamples.KeyUpBehavior = function(element) { AtlasExamples.KeyUpBehavior.initializeBase(this, [element]); } AtlasExamples.KeyUpBehavior.prototype = { // Initialize / Dispose. initialize : function() { AtlasExamples.KeyUpBehavior.callBaseMethod(this, 'initialize'); $addHandlers(this.get_element(), {'keyup':this._onKeyUp}, this); }, dispose : function() { $clearHandlers(this.get_element()); AtlasExamples.KeyUpBehavior.callBaseMethod(this, 'dispose'); }, // Event Handler. _onKeyUp : function(evt) { this._raiseEvent('keyUp', Sys.EventArgs.Empty); }, // Event add_keyUp : function(handler) { this.get_events().addHandler('keyUp', handler); }, remove_keyUp : function(handler) { this.get_events().removeHandler('keyUp', handler); }, _raiseEvent : function(eventName, eventArgs) { var handler = this.get_events().getHandler(eventName); if (handler) { if (!eventArgs) { eventArgs = Sys.EventArgs.Empty; } handler(this, eventArgs); } } } // Descriptor. AtlasExamples.KeyUpBehavior.descriptor = { events: [{name: 'keyUp'}] } AtlasExamples.KeyUpBehavior.registerClass('AtlasExamples.KeyUpBehavior', Sys.UI.Behavior); </script></body></html>

CascadingDropDowns cant fire OnSelectedIndexChanged client events?

Greetings, all...

I've got a page with a CascadingDropDown setup. On the third dropdown, I want to fire an update panel event to fetch data.

For whatever reason, it does not appear that I can get any of the three dropdowns in the cascade to recognize a client-side OnSelectedIndexChanged event - even when added programmatically in the code file.

The event/action are emitted correctly to the control, but it doesn't seem to fire the event.

I've been trying to find the answer in previous posts and Google, but I don't seem to be finding the answers anywhere. I'm hoping there's someone out in forumland that has seen this before and knows how to resolve the issue.

Thanks in advance for the help,

Ric Castagna

Unless I'm mistaken, OnSelectedIndexChanged is a server-side event, not a client-side one.