Beware with Culture setting when Converting Value

January 11, 2016 Leave a comment

Not only affect in converting or parsing Datetime, but Culture setting also affect in converting value, e.g. from double to integer. I’ve experienced it myself (you can try it if you don’t trust me :) ).

So it’s always safer if you add System.Globalization.CultureInfo.InvariantCulture parameter when Converting or Parsing any type of values.

Have a nice coding🙂

 

Categories: Uncategorized

Utilizing standard Sharepoint dialog and application pages, case: add capability to upload picture from computer in List form

December 18, 2015 Leave a comment

Standard Sharepoint dialog and application pages can be useful for making Sharepoint customization easier.

Here, I want to customize add and edit List forms to add capability to upload picture from computer to picture library and put the uploaded picture in picture field in the add or edit List form.

There are two standard Sharepoint application pages for uploading picture that I can use, i.e., Upload.aspx and RteUploadDialog.aspx, different is RteUploadDialog.aspx have upload destination option.

Lets get started:

1). I’ve List with picture field called ‘Foto’. The add and edit forms were built using Infopath. To add upload picture from computer capability, I add button called ‘Upload Foto’ to load Sharepoint upload file dialog. I also add two ‘Foto’ field controls with different type, i.e., picture and text type.

image

2). Then write javascript to load Sharepoint upload dialog and put the uploaded picture  in picture field. As usual, put the javascript code in content editor webpart or script editor webpart (in Sharepoint 2013). Cause I want to put the picture in the specified picture library, i use Upload.aspx. Here’s the code (don’t forget to put JQuery reference) :


$(‘document’).ready(function () {
$(‘input[value=”Upload Foto”]’).on(‘click’, function () {
var  picturesLibraryGuid =  ‘{2F2F4107-D023-419F-8290-ECF7F1374A2F}’;
var  options =
{
url: L_Menu_BaseUrl + “/_layouts/RteUploadDialog.aspx?LCID=1033&Dialog=UploadImage&UseDivDialog=true”,
title: “Upload a picture”,
dialogReturnValueCallback: function (result, value) {
if (result == SP.UI.DialogResult.OK) {
var srcval= window.location.protocol + “//” + window.location.host+$(value).attr(‘src’);
$(‘input[originalid=”V1_I1_T3″]’).val(srcval);
$(‘input[originalid=”V1_I1_T3″]’).trigger( “blur” ); // to trigger refresh as happened in manual action
}
}
};
SP.UI.ModalDialog.showModalDialog (options);
});
});

If you want to use RteUploadDialog.aspx instead, just change the options like this :

        var  options =
{
url: L_Menu_BaseUrl + “/_layouts/RteUploadDialog.aspx?LCID=1033&Dialog=UploadImage&UseDivDialog=true”,
title: “Upload a picture”,
dialogReturnValueCallback: function (result, value) {
if (result == SP.UI.DialogResult.OK) {
var srcval= window.location.protocol + “//” + window.location.host+$(value).attr(‘src’);
$(‘input[originalid=”V1_I1_T3″]’).val(srcval);
$(‘input[originalid=”V1_I1_T3″]’).trigger( “blur” ); // to trigger refresh as happened in manual action
}
}
};

3). And here the result:

image

image

 

References: http://omlin.blogspot.co.id/2011/07/spuimodaldialog-sharepoint.html and http://jeffywang.blogspot.co.id/2013/10/upload-images-to-sharepoint-library.html

Categories: Sharepoint Tags:

Processing multiple data in a single call SQL Query

September 22, 2015 Leave a comment

Say you want to insert multiple rows of data in single shot query, how you accomplished that ?

There are several ways. Two of them I’ve used, they are:

1. Via XML parameter.

Bundle multiple data values into XML then pass to a procedure or statement. In a procedure or statement, use Nodes method to process that data in a single call. Here’s one of the example I’ve found in the Net : http://www.thinkingcog.com/post/2014/02/15/Inserting-multiple-rows-in-SQL-Server-database.aspx

2. Via Table-Valued parameter.

Here you have to create table type first before we can use table-value parameter in procedure. Completed how-to and sample can be found in MSDN link here : https://msdn.microsoft.com/en-us/library/bb675163(v=vs.110).aspx . But remember it only available at SQL 2008 or higher.

Categories: SQL Tags:

CodeOntime Data Access Flexibility

November 23, 2013 Leave a comment

In CodeOntime, For Data Binding we can use either :

1. ControllerDataSource , that comes with CodeOntime (Aquarium) Framework .

2. ObjectDataSource, that uses business data objects that generated by CodeOntime.

For completed explanation and samples, please read this:

http://codeontime.com/learn/data-controllers/framework/controller-data-source

Categories: CodeOnTime Tags:

Create Webpart for Aggregating List using Sharepoint 2010 Search

August 22, 2013 Leave a comment

The Idea is building webpart that display content (in brief manner, with title, creator and his photo include with Microsoft Lync shorcut, created date ) from Lists (ex. blogs) that spread across the sites.

To cross the site boundaries we use Sharepoint Search.

And to specify which lists that we grab, we use Search Scope.

Here the screenshot result :

image

And here’s the code : Aggregate.zip

Categories: Search, Sharepoint 2010 Tags: ,

Error “the selected range cannot be converted to a table..” When Import from Spreadsheet

May 8, 2013 Leave a comment

I got This Error :

image

When Creating List from Spreadsheet. Then after sometimes of trying, I’ve found out that Error won’t happened when I removed the Formula. The trick to remove formula in Excell is just copy and paste to other sheet with option Values when pasting (as seen below), then use that pasted sheet for importing.

image

Categories: Sharepoint Tags:

dd/MM/yyyy in DotNetNuke

April 6, 2013 Leave a comment

It’s not easy formating datetime in dd/MM/yyyy in DotNetNuke ( in XModPro Module Form ). Finally I could do that with setting culture to fr-FR (France). I’ve got this clue from somewhere in the internet that I’ve forgot where the address is. Here is the complete code:

<div class=”xmp-form-row”>
<Label CssClass=”xmp-form-label NormalBold” For=”BirthDate”>
Tanggal Lahir
</Label>
<DateInput Id=”BirthDate” DataField=”BirthDate” DataType=”datetime” Format=”dd/MM/yyyy” culture=”fr-FR”>
</DateInput>
<CalendarImage ImageUrl=”~/DesktopModules/XModPro/images/calendar.jpg” Style=”margin-left:5px;” Target=”BirthDate” Format=”dd/MM/yyyy”>
</CalendarImage>
</div>

Categories: DotNetnuke Tags: ,