Google+

Tuesday, June 11, 2013

Testing if something is hidden with jQuery

In jQuery, it is possible to toggle the visibility of an element. You can use the functions .hide(),.show() or .toggle().
How you would test if an element has been hidden or shown using jQuery?

As, the question refers to a single element, this code might be more suitable:
$(element).is(":visible") // Checks for display:[none|block], ignores visible:[true|false]

Note:-Please comment and reply me.

Friday, March 8, 2013

Checking condition inside client template in Telerik Grid ASP.NET MVC Razor.

Hi,


I want to check some condition inside the client template. I am displaying certain model properties in ordered list some properties might be null. 
I want to check if it is empty i should not display the template.


colums.Bound(o => o.Order1).ClientTemplate( "
  1. <#= Order1 #>
  2. " + "
  3. <#= Order2 #>
  4. " + "
  5. <#= Order3 #>
" ); 



Here is a sample of a client template which is using conditions:

ClientTemplate("<# if (OrderID > 10)  { #> <#= OrderID #> <# } else { #> <#= OrderID #> <# } #>");


<# is the client-side equivalent equivalent of <% where <#= is the client-side equivalent of <%=

Thursday, March 7, 2013

Ado.net - the Size property has an invalid size of 0


I'm trying to get output value from DB via ADO.net. There's a client code:
    using (var connection = new SqlConnection(ConnectionString))
    {
        connection.Open();
        SqlCommand command = new SqlCommand("pDoSomethingParamsRes", connection);
        command.CommandType = CommandType.StoredProcedure;
        command.Parameters.Add("@i", 1);
        var outParam = new SqlParameter("@out", SqlDbType.VarChar);
        outParam.Direction = ParameterDirection.Output;
        command.Parameters.Add(outParam);
        command.ExecuteNonQuery();
        Console.WriteLine(command.Parameters["@out"].Value.ToString());
    }
When I run this I get the following exception:
the Size property has an invalid size of 0

Solutions :-

VarChar and NVarChar are variable width character fields (thus var+char). You have to set the length, otherwise the default is zero.


outParam.Size= int.MaxValue

to define maximum value of integer.

Monday, October 8, 2012

Creating existing column identity in existing table


Hi friends ,

Suppose i have one table " shipmentpincode " , which have following columns :-





 I want to make Id column of this table identity . Then i have to fulfill following steps : -


  • First , create a temp column in table 
Alter Table shipmentpincode Add Id_new int Identity(1, 1) not null primary key 
Go

  • Second, drop existing column 
Alter Table shipmentpincode Drop Column Id
Go

  • Rename new column to old column name 

  Exec sp_rename 'shipmentpincode.Id_new', 'Id', 'Column'