Friday, May 1, 2015

SP 2013 Auto Hosted App Discontinued

Share Point 2013 App Model Auto Hosted App option was in Preview and it was discontinued on 30-June-2014,

Error: When you try to deploy AutoHosted App to your O365 it will give you following error
something went wrong error

CauseMicrosoft Announcement about AutoHosted App

Now you can covert the autohosted to Provider hosted app use the following MSDN link to convert your applications.

Solution:How to Convert AutoHosted App to ProviderHosted App

Friday, April 24, 2015

Starting the SharePoint Central Admin giving runtime Error


When Starting the Share point Central Administration I get Run-time Error.

Follow the steps below

1) Go to IIS
2) Expand the "Sites" folder and select "SharePoint Central Administration v4 " virtual directory
3) In the "Actions" section click Explore
4) The site physical folder will open and contains web.config file.
5) Open web.config file find the "CustomErrors" tag.
6) Set its mode attribute to mode="Remoteonly"
7) Refresh and Re-open the central Administration Site in browser
8) You will Get the following error now

Error: This operation can be performed only on a computer that is joined to a server farm by users who have permissions in SQL Server to read from the configuration database. To connect this server to the server farm, use the SharePoint Products Configuration Wizard, located on the Start menu in Microsoft SharePoint 2010 Products.

Cause: SQL Server for SharePoint services stopped due to restart of my machine

9)  Now Open the Services.msc
10) Restart the "SQL Server(SHAREPOINT)" service
11) Also Enable and Restart the "SQL Server Agent (SHAREPOINT)"
12) Also Enable and Restart "SQL Server Browser" 

PS: I hope this helps. Please drop your comments.

Tuesday, April 14, 2015

how to use requiredfield validator with dropdownlist


Here is how we can use requiredfieldvalidator with dropdownlist.

Set the below property of the dropdownlist control

AppendDataBoundItems = true

Then Insert a default value in the Page_Load event

ddl.Items.Insert(0, new ListItem("<<-Select-->", "-1"));

Now define the required field validator and set its initialvalue attribute to "-1"

<asp:RequiredFieldValidator ID="reqddl" runat="server" Text="*" ControlToValidate="ddlRole" InitialValue="-1" SetFocusOnError="true" Display="Dynamic" ValidationGroup="Add"></asp:RequiredFieldValidator>

Happy coding :)

Monday, March 2, 2015

Hide and Show div using Jquery

We have a requirement to hide and show our Grid in a div. 

Following is the code to achieve this functionality

Define the first div which shows the caption Show/Hide. Whenever the mouse is over the div "divtoggle1" second div "divOrders" is either shown or hidden

The below <Div> is defined with caption Show/Hide

 <div id="divtoggle1" style="text-align:left;width:250px">
                 Show/Hide
  </div>

The below <Div> contains the GridView which we need to Show/Hide

<div id="divOrders">
 
<asp:GridView ID="grvOrders" runat="server" AutoGenerateColumns="False" >

     <Columns>
          <asp:TemplateField HeaderText="firstcolumn" >
                      <ItemTemplate>
                              <asp:LinkButton ID="lnkName" runat="server" Text='<%#
                                  DataBinder.Eval(Container.DataItem,"Names") %>'                                                                               CommandName="OrderDetail">
                            </asp:LinkButton>
                        </ItemTemplate>
            </asp:TemplateField>
        </Columns>
  </asp:GridView>
</div>  

The Jquery part which toggle the div

we are access the div "divtoggle" with "#" sign because in Jquery when you want to access any element by ID you have to use "#" sign before the name of element.

we call the "divtoggle1" mouseover event and in that event we are checking the second div "divOrders".

 if "#divOrders" visible then hide it or if it is hidden then make it visible. we also added delay function to make the Show/Hide smooth and we used hide argument "slow".

<script type="text/javascript">
    $(document).ready(function () {
        $("#divtoggle1").mouseover(function () {

            if ($('#divOrders').is(':visible')) {
                $("#divOrders").delay(100).hide('slow');
                $("#divtoggle1").text('Show Orders');
            }
            else {
                $("#divOrders").delay(100).show('slow');
                $("#divtoggle1").text('Hide Orders');
            }

        }); // end of mouse over
    });    // end of ready function
 

</script>

Monday, February 2, 2015

Passing-parameter-value-through-a-function-from-anchor-tag-in-a-gridview

We have a requirement where we have to pass Session values and DataBound values to Javascript function using Anchor tag in Gridview.

Following is the Anchor defined in the Gridview where we are passing Session and Eval values as parameter to the Javascript function

OpenAttachmentWindow(roomId,StudentId,Id).


Javascript function description

<script language="javascript" type="text/javascript">

       function OpenAttachmentWindow(roomId, StudentId, Id)
         {
             var ReadOnly = 0;

             window.open('UploadSupplierAttachments.aspx?roomId=' + roomId + '&studentId=' +
             StudentId + '&id=' + Id + '&ReadOnly=' + ReadOnly, '', 'width=700,height=500')
         
          }

   </script>


Gridview Template column

We have anchor html control which will pas the server side arguments to javascript function.

<asp:TemplateField HeaderText="view">

    <ItemTemplate>

           <a  onclick='<%# "OpenAttachmentWindow(" +Session["roomId"] + " , " +        
           Session["StudentId"] + ", " + Eval("Id") +" );" %>'  id="a1" runat="server" >Attachment </a>

    </ItemTemplate>

</asp:TemplateField>


Wednesday, January 21, 2015

Compare Validator DataTypeCheck


I have been using asp.net Validator controls for quite long. I have come across the unexplored property of Compare Validator which can check input against following types

1) Currency
2) Date
3) Double
4) Integer 
5) String

you can use the Validator by setting the following properties

Operator="DataTypeCheck"

Select any of the below types for data type check

Type= Currency
            Date
            Double
            Integer 
            String

Example:

<asp:CompareValidator ID="CompareValidatorNumber" runat="server" ControlToValidate="txtTelephone" Text="*" Display="Dynamic" ErrorMessage="Please enter numbers only" Operator="DataTypeCheck" Type="String"></asp:CompareValidator>