Wednesday, June 12, 2013

Create Validation for JQuery UI DatePicker exapmle

BresleveloperNS :
BresleveloperNS = BresleveloperNS || {};

BresleveloperNS.ValidateDatePicker = function (dateSelector, errorMsg) {
  $(dateSelector).blur(function () {
    BresleveloperNS.ValidateDatePicker_ValidateHandler(this, errorMsg);

BresleveloperNS.ValidateDatePicker_All =
function (errorMsg) {
  $(".hasDatepicker").blur(function () {
    BresleveloperNS.ValidateDatePicker_ValidateHandler(this, errorMsg);

BresleveloperNS.ValidateDatePicker_ValidateHandler =
function (dateSelector, errorMsg) {
  var txtDate = dateSelector.val();
  var isTxtDateValid = true;
  var dateFormat = $(dateSelector).datepicker("option", "dateFormat");
  try {
    txtDate = $.datepicker.parseDate(dateFormat, txtDate);
  catch (ex) {
    if (ex == "Invalid date") {
      isTxtDateValid = false;
    }     else {
      throw ex;

if (txtDate !== null) {
    var maxDate = dateSelector.datepicker("option", "maxDate");
    var minDate = dateSelector.datepicker("option", "minDate");
    if (maxDate != null) {
      maxDate.setHours(0, 0, 0, 0);       if (txtDate > maxDate) {
        isTxtDateValid = false;
    if (minDate != null) {
      minDate.setHours(0, 0, 0, 0)       if (txtDate < minDate) {
        isTxtDateValid = false;

if (!errorMsg) {
    errorMsg = "Invalid Date";

  if (isTxtDateValid) {
    if ("span.ValidateDatePicker_ErrMsg").length > 0) {"span.ValidateDatePicker_ErrMsg").hide();
  else {
    if ("span.ValidateDatePicker_ErrMsg").length > 0) {"span.ValidateDatePicker_ErrMsg").show();
    }     else {
      dateSelector.after("<span class='ValidateDatePicker_ErrMsg'>" + errorMsg + "</span>");"span.ValidateDatePicker_ErrMsg").css("color", "red").css("font-weight", "bold");



Thursday, June 6, 2013

Firefox - Make New Session

you need to clear the cookies.
i do it by the developers bundle add-on, cookies, Delete all 3 Domain/Path/Session Cookies

BresleveloperNS - My Javascript Namespace

*NOTE - I will update this as possible, so plz send my any suggestions to improve or make it more generic.
you can either download the entire JS file or scroll down and look for what you need!189&authkey=!ABZCTBTTOCDYGhk
Functions Summery Inside :D

the functions:
FileUpload_LimitTypes: create validation for a fileupload. can work with server check.
getQStringParameterByName: as it sais.
Alert: a JQuery modal to function as a standard alert
Confirm: a JQuery modal to function as a standard confirm with callbacks to operate afterwards
ValidateDatePicker: create validation on a datepicker for mindate, maxdate and dateformat.
ValidateDatePicker_All: as above but for all datepickers on page
PaginateTables: create a real and complete pagination for an html table 

Wednesday, June 5, 2013

Jquery UI Modal Dialog Confirmation, Return Value

well lets start by the fact that u cant, the modal is a void, it doent return anything.
but then again god gave the JS creators the though to give us Callbacks!! problems solved!
just make ur "big" function a 2-3-x part.

lets start with the confirm code, I did it very generic and u can always add/remove:

function custom_confirm(output_msg, title_msg, okBtnText, cancelBtnText, ok_callback, cancel_callback) {
  if (!title_msg)
      title_msg = 'Alert';
      title: title_msg,
resizable: false,
      modal: true,
      buttons: [{ 
          text: okBtnText,
click: function () {
             if (ok_callback){

       }, {
          text: cancelBtnText,
click: function () {
             if (cancel_callback){

the Callbacks r just simple functions like:
function myOkCallback() {
   alert('I DID IT!! I DID A CALLBACK IN JS!!');
and more Callbacks for each extra button, so u have the calling function and the callbacks, like with ajax.

p.s. to us noobs:
custom_confirm(output_msg, title_msg, okBtnText, cancelBtnText,
function() { some code... }, function() { some code... })

Being a Developer - a sad story

background - today i am developing on Sharepoint 2013, and a very important note is that is a Microsoft platform that didnt got yet its SP1, and VS2012 and i dont know if it has SP1 yet, i think not.

i left yesterday leaving everything running superb, came today and bang - error everywhere and nothing works. to the optimistics i'll say i am running my own virtual machine on my machine so nobody has touched it period.

so with SP when you develop something in VS you need to deploy everything to the IIS and other directories (sometimes build is enough).

by doing that the deployment has failed, missing some file that is there, existing.

after iisreset, reopen VS, restarting the machine, he then decided that the missing file is another file.

i morally failed and call my team leader that, after deep investigations just started to cut in the web.config all the references to this dll until the back of SP finnally opened, to the non-SP devs its a webpage of configurations that have nothing to do with the rest of the sln code.

he then started to add them 1 by 1 and the magic - everything is working. all that is after 5 hours. yey MS!!

Monday, June 3, 2013

Sharepoint Genesis how to create basic lists Tutorial and example

1 - make your Fields:
/// <summary>
/// My Field
/// </summary>
ID = "{copy paste a guid here}",
StaticName = "MyFieldName",
InternalName = "MyFieldName",
DisplayName = "$Resources:MyResource,Field_MyFieldName_DisplayName;",
Type = SPFieldType.Text,
Group = "$Resources:BoiModel,FieldGroup_MySite_Title;",
Required = false)]
public class MyFieldName : SPGENField<MyFieldName, SPFieldNumber, string>{}

2 - make your Content Type:
/// <summary>
/// My Content Type
/// </summary>
ID = "0x0100574F3398A6A141B4A6E0F56CF5B58C1B => this is from",
Name = "$Resources:MySiteModel,ContentType_MySite_Name;",
Group = "$Resources:MySiteModel,Group_MySiteContentTypes")]
public class MyContentType : SPGENContentType<MyContentType>
{   protected override void InitializeDefinition(SPGENContentTypeProperties properties)
     properties.FieldLinks.ProvisioningMode =

3 - make your List:
WebRelURL = "Lists/MyList",
Title = "$Resources:MySiteModel,ListInstance_MyList_Title;",
TemplateType = (int)SPListTemplateType.GenericList,
OnQuickLaunch = false,
ContentTypesEnabled = true)]
public class MyList : SPGENListInstance<MyList>
{   //Here we declare that this list instance will use our content type
  protected override void InitializeDefinition(SPGENListInstanceProperties properties)
     properties.ContentTypes.ProvisioningMode =
  protected override void OnProvisionFinalized(SPList list)
  {     base.OnProvisionFinalized(list);

3.5 - :
class ModelUtilities
{   public static void SetDefaultView(SPList list)
  {     SPView view = list.DefaultView;
    SPContentType ct = list.ContentTypes[0];
    view.ViewFields.DeleteAll();     for (int i = 1; i < ct.FieldLinks.Count; i++)

4 - Provisions!!! (per field, content type and list):