Tuesday, November 27, 2012

Read Telerik drop downlist javascript

sometimes we need to read the value/text of a Telerik MVC dropDownList  items.
using JQUERY:

function getData()
{
var items= $('#dropdownlistName).data('tDropDownList').data;
// items is the items list
// items can be dealt as an array
// then we can get the text and the value of each item as following:
 
var text = items[0].Text;
var value = items[0].Value;
 
 
}

Note :
you have to read $('#dropdownlistName) " after document.read() function as we have to wait for  the Telerik JQuery library to be loaded.
it is preferred to be read pageLoad function of the Microsoft.Ajax library

function pageLoad()
{
    getData()
}

or at any event handler javascript function

Wednesday, November 14, 2012

certification under Network Service account


When your application use certification and you have a windows service, and  you set the user of the windows service to be for example Network Service to be able to access resources on network by the windows service , you may get the following exception

It is likely that certificate 'CN=XX' may not have a private key that is capable of key exchange or the process may not have access rights for the private key. Please see inner exception for detail. Keyset does not exist

 

 That mean the Network Service account have no access for the certification

Then You have to give authority for the Network Service account to access your certification

Then you can use WinHttpCertCfg

WinHttpCertCfg.exe -g -c LOCAL_MACHINE\MY -s "MyCompany" -a "NetworkService"

 

Reference

Wednesday, August 8, 2012

WIX..enforce overwrite files & more

If user had installed a product before and want to uninstall to reinstall same version but new build

sometimes the user need to delete the files manually from the installaton directory

so it is better for the product to force reinstallation for all the files , registry keys and others to avoid user undeletion

WIX support this by adding the follwing property to the Main fragment of the WIX project    
 <Property Id="REINSTALLMODE" Value="amus"/>


which mean:

a - Force all files to be reinstalled, regardless of version.
m - Rewrite all registry keys that go to HKEY_LOCAL_MACHINE or HKEY_CLASSES_ROOT.
u - Rewrite all registry keys that go to HKEY_CURRENT_USER or HKEY_USERS.
s - Reinstall shortcuts and icons.

Sunday, May 6, 2012

Ajax Autocomplete extender doesnt retrieve data on IIS

when building asp.net website with start option set to "IIS"  and test an autocomplete extender that retrieve data using a webservice  , it doesnt retrieve data
using "Fiddler" to catch the error , it gets

System.InvalidOperationException: Request format is invalid: application/json; charset=utf-8.
at System.Web.Services.Protocols.HttpServerProtocol.ReadParameters()
at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()

solution  :
at the web.config file  =>system.webserver => handlers => add these lines

 <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
 <add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
  

Tuesday, January 10, 2012

Get days between 2 different times


/*get the all "dayeNumber" days between the begin and end date -- Sunday dayeNumber = 1 */


create FUNCTION [dbo].GetDays

( 

@dayNumber int ,@BeginDate datetime,@EndDate datetime

)
RETURNS @days TABLE(date datetime)

AS

Begin

declare
 @diff int

if @dayNumber > datepart(dw,getdate())

set @diff= @dayNumber- datepart(dw,getdate())

else

set
 @diff= @dayNumber- datepart(dw,getdate()) +7

set @BeginDate =(Select DATEADD(day,@diff,getdate()))

set @EndDate = (Select DateAdd( month,5,getdate()))

-- get days
WHILE @BeginDate <= @EndDate BEGIN

INSERT INTO @Days SELECT @BeginDate

SELECT @BeginDate = DATEADD(dd, 7, @BeginDate)

ENDreturn

end