Thursday, 23 June 2016

Hide Submit button after the InfoPath Form is submitted - SharePoint 2013

This seems simple but, to me, it took a while to figure out how to achieve this. So I thought I should write a post for other guys out there trying to get same results.

No more talking. Let's get started!!

NOTE: I assume that you have InfoPath Form published on a SharePoint site with Submit functionality enabled.

Our Scope is: We want to show the Submit button only for the very first time when the form is being filled by user. Once user submit the form, the Submit button will not be shown ever if the form is opened again.

Below are the steps to achieve this:
  1. Every InfoPath Form with submit functionality enabled has Submit, Save, Save As and etc. buttons by default in the Ribbon.
  2. To achieve what we want, we need to get rid of Submit Button from the Ribbon. To do so, open your form in InfoPath Designer and do as follows-
    • Goto File > Advanced form options > Web Browser > Uncheck Submit
    • Add a Button Control at the top of your page. Right click on it and set the values as shown below:
      Hit OK.
    • Add a New Field from fields toolbox.To do so, right click on myfields node > Add > use setting as shown below:
    • Add Formatting Rule to your button. Use below Condition:
      Hit OK. Check the checkbox "Hide this control"
    • Publish (not Quick Publish) your form again. Add New Field as column when it asks. Make sure you check "Allow user to edit data in this field by using a datasheet or property page."
    • Add a Workflow that starts whenever an Item is Created. Use the following statements:
      Publish Worklfow.
  3. You are all set! Try to submit your form and open it again. Submit button is gone.
Views? Questions? Feel free to let me know in the Comments section below.

Wednesday, 3 June 2015

Creating New Master Pages for SharePoint Site - SharePoint 2013

If you are having an requirement to create different layout for different set of pages in a SharePoint site then you are reading right post.
To use different layout for SharePoint site you can use SharePoint Designer 2013.

Steps to achieve this-
1. Once you login to the site from SharePoint Designer 2013, click on 'Master Pages' from Navigation area on the left side.

2. From the Ribbon click on 'Blank Master Page' and give it a name.

3. You'll have a page with basic HTML structure which you can change the way you want. Make desired changes to meet your requirements.

Now you have Master Page ready. To create content page follow these steps-
1. Go back to 'Master Pages' section. Right click on the Master Page you just created and select 'New From Master Page'

3. Enter Name for your content page and click OK.

2. Add the controls to the content page that points to the controls in the master page you just created.

Hope this would help you. If you have any question, do not hesitate to leave comment.

Friday, 2 May 2014

CSS Designs - Buttons to wow your user's experience

Here are some very simple and good looking button designs that you can use to match with the layout of your website.

Flat Button

<input type="button" id="flat" value="Flat Button" />

padding: 10px 60px;
border: none;
background-color: #00A0B1;
color: #fff;

Round Button

<input type="button" id="round" value="Round Button" />

padding:10px 60px;
background-color: #643EBF;
color: #fff;
border-radius: 8px;

Ellipses Button

<input type="button" id="ellipses" value="Ellipses Button" />

padding: 20px 60px;
border: none;
background-color: #2E8DEF;
color: #fff;

Circle Button

<input type="button" id="circle" value="Circle Button" />

background-color: #A700AE;
color: #fff;

Shadow Button

<input type="button" id="shadow" value="Shadow Button" />

padding: 10px 60px;
background-color: #BF1E4B;
color: #fff;
box-shadow: 2px 2px 5px black;

Text Shadow Button

<input type="button" id="textshadow" value="Text Shadow Button" />

padding: 10px 60px;
background-color: #DC572E;
color: #fff;
text-shadow: 2px 2px 2px black;

Embedded Text Button

<input type="button" id="embedded" value="Embedded Text Button" />

padding: 10px 50px;
border: none;
background-color: rgba(0,0,0,0.3);
color: rgba(0,0,0,0.7);
font-weight: bold;
text-shadow: 0 1px 1px whitesmoke;

Combining All

<input type="button" id="btn" value="Button" />

padding: 10px 60px;
border: none;
background-color: #0A5BC4;
color: #fff;
text-shadow: 1px 1px 2px black;
box-shadow: 0 0 3px black;

Thursday, 13 March 2014

Difference between SelectedIndex, SelectedValue and SelectedItem in ASP.NET

Controls that uses Collections to store data usually have these three properties. Example of these controls are ListBox, Dropdown, RadioButtionList and CheckBoxList. I have seen that alot of people gets confused with these three properties like how and where to use them.
Each of above controls holds two kinds of data. One is DataValueField and other is DataTextField. DataValueField is something that is not shown to user. DataTextField is shown to the user.

SelectedIndex property always returns the index of selected item in the control. Index always starts from 0. The first item in the control has 0 index and second item has 1 index and so on.

Well, this is the property with which people are confused the most. Most of them thinks that SelectedValue property returns the text of the item we have selected. Yes it returns the text BUT only when you have not specified the value separately. The value in these controls is something which is not shown to the user.
Let's take an example, you are adding items into ListBox1 dynamically like-


When you do like this then the text and value of this item becomes "iknowledgeboy". So, when you say-


then you get "iknowledgeboy" for sure. BUT when you are binding your ListBox1 with Database then you need to specify DataTextField and which is DataValueField of ListBox1. At that time, the value of each item in ListBox1 or Dropdown or CheckBoxList or RadioButtonList is usually integer. So, then if you say-


then you won't get the text that you are seeing rather you will get that integer value.

It is best method of retrieving the text as well as value. SelectedItem property helps us to get both Text and Value. The problem that people face with this property is they just simply writes-


Well, this will give you error for sure. Because it not returning you the text but it is returning you the ListItem. So, if you want to get the text of selected item then you have to write it like this-


and to get the value of same you have to write-


This is how SelectedItem works.
Hope you find this usefull.

Thursday, 6 March 2014

Creating Thumbnail Image by keeping Aspect Ratio using C#

I am using a large picture (High Resolution) and then I will create its thumbnail.

Suppose that I need a thumbnail whose width should be maximum 200px. Now, while creating a thumbnail of a large image we also need to provide its height. So, how do we get to know about its height by keeping its aspect ratio also. Well, it can be achieved using very simple mathematical equation.

Lets do all this by writing code. I am doing this on a click of a button.

protected void Button1_Click(object sender, EventArgs e)
    //----------        Getting the Image File
    System.Drawing.Image img = System.Drawing.Image.FromFile(Server.MapPath("~/profile/Avatar.jpg"));
    //----------        Getting Size of Original Image
    double imgHeight = img.Size.Height;
    double imgWidth = img.Size.Width;

    //----------        Getting Decreased Size
    double x = imgWidth / 200;
    int newWidth = Convert.ToInt32(imgWidth / x);
    int newHeight = Convert.ToInt32(imgHeight / x);

    //----------        Creating Small Image
    System.Drawing.Image.GetThumbnailImageAbort myCallback = new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback);
    System.Drawing.Image myThumbnail = img.GetThumbnailImage(newWidth, newHeight, myCallback, IntPtr.Zero);

    //----------        Saving Image
public bool ThumbnailCallback()
    return false;
Original Image

Thumbnail Image