I’ve finally gotten around to updating wordpress and adding some plugins to fight against the huge amount of spam I was getting. Although no upgrade ever goes 100% the way it was supposed to. So there’s some things that didn’t get moved over and some dead links here and there.
If you find something feel free to leave a comment or shoot me an email.
Thanks
General
I was working on some UI issues today at work. I ran into what, at the time seemed like a very simple problem/bug. When the uses pressed the enter key, nothing would happen. I’ve seen this problem before and fixed it with a quick bit of JavaScript to capture the keycode and submit the default form of the page.
Of course this didn’t work for this problem (that would be too easy). After fiddling around with it for awhile trying to get the onclick of the button to fire when the enter key was pressed and many other configurations. I turned to google and found a, new to me, feature of asp.net 2.0
The form:
< span style=”font-size: medium; font-weight: bold;”>Name: span>
< asp:TextBox ID=”txtSearchQuery” runat=”server” Width=”200″/>
< asp:TextBox ID=”TextBox1″ runat=”server” style=”visibility:hidden;display:none;” />
< span id=”asOptions” style=”width: 200px;font-weight: bold; padding-left: 10px”>Contact type:
< asp:DropDownList ID=”advancedSearchOptions” runat=”server”>
< asp:ListItem Text=”Person” Selected=”True” />
< asp:ListItem Text=”Organization” />
asp:DropDownList>
span>
< asp:Button ID=”btnSearch” Text=”Search” runat=”server” OnClick=”btnSearch_Click” />There are also two more buttons that are in the page. This is what was causing asp.net to not fire an event when I pressed enter on the text box. With asp.net you now have the option of adding “DefaultButton” to a panel or form tag. This will fire the right event depending on where the cursor is on the form. Fix:
< asp:Panel DefaultButton=”btnSearch” ID=”defButton” runat=”server”>
< span style=”font-size: medium; font-weight: bold;”>Name: span>
< asp:TextBox ID=”txtSearchQuery” runat=”server” Width=”200″/>
< asp:TextBox ID=”TextBox1″ runat=”server” style=”visibility:hidden;display:none;” />
< span id=”asOptions” style=”width: 200px;font-weight: bold; padding-left: 10px”>Contact type:
< asp:DropDownList ID=”advancedSearchOptions” runat=”server”>
< asp:ListItem Text=”Person” Selected=”True” />
< asp:ListItem Text=”Organization” />
asp:DropDownList>
span>
< asp:Button ID=”btnSearch” Text=”Search” runat=”server” OnClick=”btnSearch_Click” UseSubmitBehavior=”false”/>
asp:Panel>
General
So I was bored and thought I’d play around with some Javascript for awhile to get back in my groove.
Here’s what I came up with: http://www.codeheadz.net/asciiani.html :D
General
I’ve been fooling around with advAjax (Site is down. Here’s the js file — I’d highly suggest you look into jQuery instead, if you can.) for a few years now. All for simple calls, which the small amount of documentation sufficed. However, the last few weeks I’ve had to use the library a lot more for work. I know it’s rather odd to be using a 3rd party Ajax library like this instead of something like ASP.NET Ajax (Oh…In case you didn’t know I work with asp.net 2.0 all day). I started using ASP.NET Ajax but it was causing a lot of problems with existing JavaScript and other 3rd party controls (Note: This was beta times so who knows if it works now). I also tried ComponentArt Callbacks but found them to be too limited for my needs. So now back to the reason for this blog. I needed to check a value before I would submit an asp.net form. This was a huge headache because, admittedly, I’m not the best at AJAX; I’ve only dabbled. I was having the problem that it was submitting the form THEN returning my AJAX call. After spending hours on this I found that I needed to set my XMLHttpRequest object to be non asynchronous Ajax call.
Great, so now I know what I NEED to do. But how the heck do I do it? I checked the documentation, google, google groups, other people. I turned up with nothing. So I dove into the code and magically it came to me. There is a field called ‘async’ it’s set to true and I needed it false. So simple enough just add that to your call.
As you see below you can modify the methods by adding them to your advAjax call
advAJAX.get({
async : false,
url: ‘../AjaxCallback/Director.aspx’,
parameters : {
“command” : ‘check_initials’,
“initials” : str,
“username” : get_txtUsername().value
}});
List of available (undocumented) fields:
obj.async = true;
obj.mimeType = “text/xml”;
obj.username = null;
obj.password = null;
(I thought the list was going to be longer…should have looked before I started writing
)
Anywho, that’s the long drawn out version of what I’ve figured out.
General