Thursday, March 17, 2011

IE dropdown width issue, IE dropdown width problem,internet explorer dropdown list

IE dropdown width issue, IE dropdown width problem,internet explorer dropdown list
We can add tooltip to all list items but in server side we have to add by loop. it is not feasible if u already
coded, or too many items can bind in dropdown list.
We can add tooltip for elements which are cutting in IE sample code is following it is based on jQuery

1)
<asp:DropDownList ID="DropDownListIEIssue" onmouseover="return test(this);" runat="server" Width="100">




</asp:DropDownList>




 
2)
 
3)
if (!IsPostBack)


{

string[] test = new string[] { "dddddddddddddddddddd", "aaaaaaaaaaaaaaaaaa", "bbbbbbbbbbbbbbbbbbbbbbbbbbbbb", "ccccccccc" };

DropDownListIEIssue.DataSource = test;

DropDownListIEIssue.DataBind();

}
 
Thanks
Mahesh K. Sharna
$("option", sender).each(function () {
function AddToolTipOnDropDownLists(sender)
{
  try
   {
       $("option", sender).each(function () {
       $(this).attr("title", $(this).html());
       });
      /*For slected element*/
       $(sender).attr('title',$('option:selected',sender).html())
   }
catch (Exception)
  {

  }
}

Thursday, March 10, 2011

Logic in sorting (ASC/DESC) null in sorted column should be always bellow in values MS SqlSever


We need the logic in sorting (ASC/DESC) the null  of sorted column should be always bellow in values.
SQuery for MS SQL SERVER


create table #temp ( inde int, inde2 varchar(20))
insert into #temp values (null,'vvv')
insert into #temp values (1,'zzz')
insert into #temp values (2,'bbb')
insert into #temp values (null,'rrr')
insert into #temp values (null,'tttt')
insert into #temp values (1,'aaaa')

For example in #temp table if we sorted desc order than it should return 2,1,1 null,null,null and when we sort it by ASC than it should 1,1,2,null,null,null
We can achive this by following query


select * from #temp order by (case when inde IS null then 0 else 1 end) desc, inde desc

select * from #temp order by (case when inde IS null then 0 else 1 end) desc, inde asc

Thanks
Mahesh K. Sharma





Wednesday, March 2, 2011

How to set the text for a TextBox with TextMode as Password asp.net

If we have to show the text value in text box where TextM ode property is set to password.

string password ="TestPassword";

TextBoxPassword.Attributes.Add("value", password);

Thanks
Mahesh K. Sharma