Tuesday, January 31, 2006

Today, I was trapped in an interesting issue while  implementing a auto-complete URL dropdown in my new C# WinForm application. As in IE, I was able to select a url after it was visible in the dropdown but after selecting, enter press was just being ignored. (rather in IE, hitting enter enters the selected value in the box. I simply tried to implement KeyDown event for the ComboBox but to my despair, all the keys but "Enter" was being caught in the event by enter key wasn't invoking the event at all...

 

I went around Googling and it was not very late when I found the solution. and it was "Overriding IsInputKey  method to have Enter key handled. here is the code..

 

public class YourComboBox : ComboBox

{

            public YourComboBox() : base()

            {

            }

            /// <summary>

            /// Key Handler

            /// </summary>

            /// <param name="keyData"></param>

            protected override bool IsInputKey(Keys keyData)

            {

                        if (keyData == Keys.Enter)

                                    return true;

 

                        return base.IsInputKey (keyData);

            }

}

 

Now your Combo box should be driven from YourComboBox  and simply KeyDown event should be caught..(with little care)

 

 

private void yourComboBox1_KeyDown(object sender, KeyEventArgs e)

{

            if (e.KeyCode == Keys.Enter)

            {

                        e.Handled = true; //remember this line to tell base function that you handled the event already...

                        //Do something...

            }

}

 

 

This and you are all set...

 

Cheers!!

 

 

 

posted on Tuesday, January 31, 2006 12:43:23 PM (Central Standard Time, UTC-06:00)  #    Comments [3] Trackback
 Monday, January 16, 2006

I have recently moved my blog from community server to dasBlog. While setting up google Adsense ads on the site, I was caught up in a specific requirement as in where to put the ads. Google suggests that for high CTR ratio, ads should be placed just above the content and this left me searching for ways to put adsense in start of First Post's body content.

A simple way to implement this was modify your latest post every time you write a post ... cumbersome huh?? Not only cumbersome, this also invalidates your RSS as the feeds doesn't allow <_SCRIPT_> tag in the XML. Looked around little more thinking that I might not be the first one having this kinda requirement ...but to my disappointment, I couldn't find any such generic way to achieve this...

finally this is what I used as a workaround...I don't claim that this is the best possible way to do it but given my one day old relationship with with dasBlog code....this is the most generic change I could make to have it working for me...(Yes you read  it right...there is little code change in newtelligence.DasBlog.Web.Core.dll)..

here is what I did...

  1. First create a category named "AdPost" and add first post to it.
  2. Then modify site.config file to add one more element..Look closely for html tags converted to literals...

<InContentAdsense>
&lt;DIV style=&quot;PADDING-RIGHT: 5px; PADDING-LEFT: 5px; FLOAT: right; PADDING-BOTTOM: 5px;PADDING-TOP: 5px&quot;&gt;
&lt;SCRIPT type=text/javascript&gt;&lt;!--
google_ad_client = &quot;pub-123123123123123123&quot;;
google_alternate_color = &quot;FFFFFF&quot;;
google_ad_width = 300;
google_ad_height = 250;
google_ad_format = &quot;300x250_as&quot;;
google_ad_type = &quot;text&quot;;
google_ad_channel =&quot;&quot;;
google_color_border = &quot;EEEEEE&quot;;
google_color_bg = &quot;FFFFFF&quot;;
google_color_link = &quot;355EA0&quot;;
google_color_url = &quot;355EA0&quot;;
google_color_text = &quot;333333&quot;;
//--&gt;
&lt;/SCRIPT&gt;
&lt;SCRIPT src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot; type=text/javascript&gt;
&lt;/SCRIPT&gt; &lt;/DIV&gt;
</InContentAdsense>

Note: By this change there was some issues with configuration update page which I'll figure out later...

    3.  Set up thecodebase and add this code and declarition in SiteConfig.cs under project <b>newtelligence.DasBlog.Web.Core</b>


string inContentAdsense = null;   //to be added in declarition
public string InContentAdsense
 {
get { return inContentAdsense; }
set { inContentAdsense = value; }
}

      4. In the same project open Macros.cs and modify method ..public virtual Control Items{ ....}

         here is the modification....

string cntnt = entry.Content;
if (entry.Categories.IndexOf("AdPost") != -1)
{         
  entry.Content = requestPage.SiteConfig.InContentAdsense +  cntnt;
}
requestPage.ProcessItemTemplate(entry, itemPlaceHolder);
entry.Content = cntnt;

 

All this and you are ready to roll....Replace your web dll with this dll (newtelligence.DasBlog.Web.Core.dll) and place the config settings in right place.....Now in whichever post you wanna show Adsense, just add it to category  AdPost!!!! don't forget to reove other posts from AdPost category as google allowes only 3 instances of an add to be displayed!!!  On request I can forward you my copy of newtelligence.DasBlog.Web.Core.dll which would cover step 3 and 4.

Hope there would be a much streamlined solution provided for this in next version of dasBlog...

Cheers!!

 

posted on Monday, January 16, 2006 5:52:16 AM (Central Standard Time, UTC-06:00)  #    Comments [1] Trackback
 Wednesday, January 11, 2006
Microsoft announced a major win today in retails sector. Target Corporation, the national's second-largest discount general merchandise retailer, is headed to adopt Microsoft® .NET Framework based technologies within its 1,400 stores in 47 U.S. states. Target will migrate its systems within each store to the Microsoft .NET Framework 2.0, Windows Serveral 2003 and Microsoft SQL Server⢠2005, core technologies that deliver on the Microsoft Smarter Retailing strategy for connecting people, information, systems and devices.

According to Janet Schalk, chief information officer at Target Corporation, Microsoft technologies can help us drive down costs through a simplified architecture and easier-to-use development tools, These cost savings will enable us to invest in additional innovations that will enhance the store experience for our guests.

Microsoft provides technologies to Target in other key operational and customer-facing areas as well. This comes as a great example of Microsoft Smarter Retailing (http://www.microsoft.com/smartretail), an initiative designed to help retailers improve how they sell and operate. Read the full story here

posted on Wednesday, January 11, 2006 7:37:00 AM (Central Standard Time, UTC-06:00)  #    Comments [0] Trackback
 Monday, January 09, 2006

After un-installing SQL Server 2005 Beta version, I started facing issues with my SQL 2000 installation and it was shooting an strange error...

SQLDMO has not been registered, please re-run SQL Server setup and contact your system administrator”.

  After some analysis, i figured out that the issue was with SQLDMO.dll registration which went for a toss because of 2005 beta un-installation.  To fix the DMO try running this:

Regsvr32 [SQL folder Program Server]\80\Tools\Binn\SQLDMO.dll

This brakes the registration of SQL Server 2005 dll registration...so make sure you are doing this after un-installation of 2005 beta...

posted on Monday, January 09, 2006 6:03:00 PM (Central Standard Time, UTC-06:00)  #    Comments [0] Trackback