Thursday, June 28, 2012

The Phases of the ClickOnce Trust Prompt


Intersting article ( written originally by Mary Lee )
Signing your Office solutions with a certificate is a mandatory step, but there are several optional steps that can change the way the certificate is presented to the end user or customer.
This example uses a Visual Studio generated test certificate, but the dialog box is similar to what you would see if you are using a purchased code-signing certificate. These steps are listed in the How to: Add a Trusted Publisher to a Client Computer for ClickOnce Applications topic in the MSDN Library and assumes that the ClickOnce Trust Prompt and inclusion list are enabled as outlined in How to: Configure Inclusion List Security
Phase 1. If the certificate used to sign the Office solution is not added to the Root or the TrustedPublisher stores, the Publisher is shown as Unknown Publisher and there is a yellow shield presented in the Microsoft Office Customization Installer dialog box.
clip_image002

Phase 2. If the certificate used to sign the Office solution is in the Root store, but not the Trusted Publisher list, the Publisher is shown as Redmond\marylee and there is a green shield.
The step used to add the certificate to the Root store is the following: certmgr.exe -add good.cer -c -s -r localMachine Root
clip_image002[5]

Phase 3. If the certificate used to sign the add-in is in the Root list and the Trusted Publisher list, you only see that the add-in was installed successfully.
The step used to add the certificate to the TrustedPublisher store is the following: certmgr.exe -add good.cer -c -s -r localMachine TrustedPublisher
clip_image002[7]


Friday, June 22, 2012

Upload files to SharePoint Doc Library from ASP.NET


Upload files to SharePoint Doc Library from ASP.NET

Upload files to SharePoint Doc Library from ASP.NETHere is the custom code to upload files to SharePoint doc library from ASP.NET. You could use the SharePoint API if you are on the same server or using web services.
Here is the sample code assuming that you know the URL of the document library and to load the document to the root folder. You have to add Microsoft.sharepoint.dll reference to your project ASP.NET
using (SPSite siteCollection = new SPSite(url))
{
using (SPWeb spWeb = siteCollection.OpenWeb())
{
SPList spList = spWeb.GetList(url);
string fileName = "XXXX";
FileStream fileStream = null;
Byte[] fileContent = null;
try
{
string docPath = XXXX; //physical location of the file
fileStream = File.OpenRead(docPath + fileName);
fileContent = new byte[Convert.ToInt32(fileStream.Length)];
fileStream.Read(fileContent, 0, Convert.ToInt32(fileStream.Length));
spList.RootFolder.Files.Add(spList.RootFolder.Url + "/" + fileName, fileContent, true);
spList.Update();
}
catch(Exception ex)
{
}
finally
{
if (fileStream != null)
{
fileStream.Close();
}
}
}
}

Wednesday, June 13, 2012

How to add DatePicker jquery functionnality to a page using Master Page File

Hi all


If you try to add a DatePicker JQuery Control in a page that uses a Master Page file the same way you do in a normal aspx page , It won't work!


What's the problem ?? 
In fact , remember that jquery uses javascript for event driven on HTML control, so in order for jquery to effective asp.net control simply define your asp.net text control as a client side control in

<script type="text/javascript">
    $(function() {
        $('#txtDate').datepicker({
            changeMonth: true,
            changeYear: true
        });
    });
    </script>

<div class="demo">

<p>Date: <asp:TextBox ID="txtDate" runat="server"></asp:TextBox></p>

</div>

instead define it as this


<script language="javascript" type="text/javascript">
    $(document).ready(function() {
        $('#<%= txtDate.ClientID %>').datepicker({changeMonth: true,
            changeYear: true});
    });
    </script>
<div class="demo">
    <asp:TextBox ID="txtDate" runat="server" >click to select date</asp:TextBox><asp:ImageButton
        ID="datepicker" runat="server" />
    </div>

which make the server (asp.net control) control to regenerate as a client control when executed. I've also tried in creating it as a user control and believe me it works perfectly
For those who are intersted, I can prepare a template project as a live Demo, just drop me an email!
Good programming


Ibtissam