Wednesday, 18 April 2012

disable resizing a multi line text box



<style type="text/css">
    textarea {resize:none;}
</style>

Or

<asp:TextBox ID="TextBox1" runat="server" TextMode="MultiLine" style="resize:none;"></asp:TextBox>




Tuesday, 17 April 2012

asp:Menu rendering problems in IE8, Safari and Chrome

I was caught off-gaurd today when a user of one my applications reported that the asp:Menu was not rendering properly in her IE browser. I checked the version and it was IE8. I changed the application to compatibility view and the menu rendered just fine.
Since I cannot tell each and every user to view the app in compatibility view when in IE8, i started digging for solutions. It looked like a z-index problem to start with. The problem was that since the new IE8 is moving closer to standards, the z-index value was set to "auto" when not specified. I tried changing it something bigger than its container's z-index value woo-hoo...it worked.
I just added this line in the CSS class definition:

z-index : 100/* Setting z-index because of an IE8 bug */
Since it is a bug, there are some hotfixes available from MS here.
This problem prompted me to look for rendering in Chrome and Safari also.
The asp:Menu control looks horrible in Chrome. There are no popups, just plain static text. I stumbled upon this thread which discusses this problem. I did not use the method posted in that thread, instead, I used a solution posted by user Mark Perkins which to me looked like the simplest and cleanest solution. Here is what he posted:
Put this piece of code in your Master page code file:
// Adding this override so that the asp:Menu control renders properly in Safari and Chrome
    protected override void AddedControl(Control control, int index)
    {
        if (Request.ServerVariables["http_user_agent"].IndexOf("Safari"StringComparison.CurrentCultureIgnoreCase) != -1)
        {
            this.Page.ClientTarget = "uplevel";
        }
        base.AddedControl(control, index);
    }

Monday, 16 April 2012

SQL - CASE in a WHERE clause

Case statement in where clause

  1. SELECT T2.*, T1.*
  2.      FROM T1, T2
  3.    WHERE (CASE WHEN T2.COMPARE_TYPE = 'A' AND
  4.                      T1.SOME_TYPE LIKE 'NOTHING%'
  5.                 THEN 1
  6.                 WHEN T2.COMPARE_TYPE != 'A' AND
  7.                      T1.SOME_TYPE NOT LIKE 'NOTHING%' 
  8.                   THEN 1
  9.                ELSE 0
  10.           END) = 1

    Result

    C        SEQ SOME_TYPE
    - ---------- -----------
    A          1 NOTHING 1
    A          2 NOTHING 2
    B          3 SOMETHING 1
    B          4 SOMETHING 2
    B          5 SOMETHING 3
    B          6 SOMETHING 4

Monday, 26 March 2012

To Reference ASP.Net Master page content, content pages


To Access Content Page TextBox Value in MasterPage:

TextBox txtB = (TextBox)ContentPlaceHolder1.FindControl("txtContentPg");
txtMaster.Text = "Content Page TextBox Value: " + txtB.Text;

To Access Master Page Label Value in ContentPage:

Label l1 = (Label)Master.FindControl("lblMaster");
lblContentPg.Text = "Master Page Label = "+l1.Text;

Wednesday, 23 November 2011

clear combobox Items

dim strEmpty as string={}

combobox.datasource=strEmpty

combobox.databind()

Tuesday, 22 November 2011

Case sensitive search in SQL Server queries

Password Case Sensitive Search

Use COLLATE clause in your T-SQL statement.

SELECT * FROM dbo.TableName WHERE username=@username 
and Password = @ password COLLATE SQL_Latin1_General_CP1_CS_AS

Tuesday, 15 November 2011

Cannot use a leading .. to exit above the top directory

What this means is that your web page is referring to content which is in the folder one level up from your page, but your page is already in the website's root folder, so the relative path is invalid. Judging by your exception message it looks like an image control is causing the problem.
You must have something like:-
<asp:Image ImageUrl="..\foo.jpg" />
But since the page itself is in the root folder of the website, it cannot refer to content one level up, which is what the leading ..\ is doing.