Sunday, May 4, 2014

add title to ajax extender popup


example

<asp:scriptmanager id="ScriptManager1" runat="server">
</asp:scriptmanager>

<asp:button id="Button1" runat="server" text="Button" />

<cc1:modalpopupextender id="ModalPopupExtender1" runat="server"
cancelcontrolid="btnCancel" okcontrolid="btnOkay"
targetcontrolid="Button1" popupcontrolid="Panel1"
popupdraghandlecontrolid="PopupHeader" drag="true"
backgroundcssclass="ModalPopupBG">
</cc1:modalpopupextender>

<asp:panel id="Panel1" style="display: none" runat="server">
<div class="HellowWorldPopup">
                <div class="PopupHeaderClasss" id="PopupHeader">Header</div>
                <div class="PopupBody">
                    <p>This is a simple modal dialog</p>
                </div>
                <div class="Controls">
                    <input id="btnOkay" type="button" value="Done" />
                    <input id="btnCancel" type="button" value="Cancel" />
</div>
        </div>
</asp:panel>

<style>
.PopupHeaderClasss{
padding0.3em 0.1em;
 text-alignleft;
 border:solid 1px black;
 background-color#5871c3;
 font-weight:bold;
    }
</style>

Wednesday, December 25, 2013

The database could not be exclusively locked to perform the operation. (Microsoft SQL Server, Error: 5030)


First we will see how to set the database to single user mode,

ALTER DATABASE dbName
SET SINGLE_USER WITH ROLLBACK IMMEDIATE

Now we will try to rename the database

ALTER DATABASE dbName MODIFY NAME = dbNewName


Finally we will set the database to Multiuser mode


ALTER DATABASE dbNewName
SET MULTI_USER WITH ROLLBACK IMMEDIATE


source :
http://weblogs.asp.net/varadam/archive/2012/08/10/the-database-could-not-be-exclusively-locked-to-perform-the-operation-microsoft-sql-server-error-5030.aspx

Wednesday, November 20, 2013

read only property and XmlSerializer

I had an issue serializing a class using the XmlSerializer, where the class had a collection property.

example:

public List<Employee> Subordinates { getprivate set; } 

if the property setter was public then everything works fine and the property serialized .
but if the property has a private setter then the following exception is thrown

Unable to generate a temporary class (result=1). error CS0200: Property or indexer '[namespace].Subordinates' cannot be assigned to -- it is read only

The problem was that the class exposed the collection property as a readonly property, but the XmlSerializer needs the property to be read/write access

so the solution is to make the property with public setter as follows
public List<Employee> Subordinates { getset; }  

Monday, January 7, 2013

Give user acess to a certification


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 "IssuedToName" -a "AccountName"

Note AccountName is the name of a local computer account or a domain account. IssuedToName is the name of the company or domain to which the client certificate was issued.

 

Reference

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.