Thursday, 19 January 2012

Restore Database SQL Service Using Command


1. Command to Restore Database form Bak File.

RESTORE DATABASE [MyDB] FROM  DISK = N'D:\Backup\DBBackup\ MyDB .bak' WITH  FILE = 1,  NOUNLOAD,  REPLACE,  STATS = 10
GO

2. Thank for Reading this Blog.

our new blog site : http://blog.hintechnology.com

Calling Web Service Using Jquery Ajax



1. Create the Web Service To Send Email and Call that Web Service Using JQuery.

i. Create a form 















2. On the SubMit Button Write the Following Code on its OnClientClick="retun CallServiceMail()".

<script type="text/javascript">
        function CallServiceMail() {
            var name = $('#nameMsg').val();
            var email = $('#emailMsg').val();
            var phone = $('#phoneMsg').val();
            var messageemail = $('#messageMsg').val();
            var messageto = "info@abakinfotech.com";
            var subjectemail = "Enquiry from web site contact form";
            $.ajax({
                type: "POST",
                url: "SendEmail.asmx/SendMail",
                data: "{'nameemail': '" + name + "', 'emailid': '" + email + "', 'phone': '" + phone + "', 'message': '" + messageemail + "', 'emailTo': ' " + messageto + "', 'subjectemail': ' " + subjectemail + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: OnSuccess,
                error: OnError
            });
            function OnSuccess(data, status) {
                if (data.d == "1") {
                    $('#nameMsg').attr("value", "");
                    $('#emailMsg').attr("value", "");
                    $('#phoneMsg').attr("value", "");
                    $('#messageMsg').attr("value", "");
                    $("#contactsubmit").show();
                    window.location = "thankyou.html#successMsg"
                }
            }
            function OnError(request, status, error) {
                if (request.statusText == 0) {
                    $("#contactsubmit").show();
                    alert("There is some error in sending mail, sorry for incovinience");
                }
            }
        }
    
</script>
</div>

our new blog site : http://blog.hintechnology.com

Send Email Using Gmail in Asp.net




1. Add the following text in the Web.config file for the your application.

<system.net>
  <mailSettings>
<smtp deliveryMethod="Network" from="sendmail@gmail.com">
<network host="smtp.gmail.com" password="password12
                                  userName="sendmail" defaultCredentials="false" port="587" />
</smtp>
  </mailSettings>
</system.net>

  i  . sendmail@gmail.com In this place enter your gmailid
  ii . sendmail In this place enter your gmailid
  iii. password12 In this place enter your gmailpassword

2. Create this form.























2. Add this method to send your mail & call where ever its required.

    public void SendMail(string FromEmail, string ToEmail, string CC, string subject, string body)
    {
        System.Web.Mail.MailMessage Message = new System.Web.Mail.MailMessage();
        Message.From = FromEmail;
        Message.To = ToEmail;
        Message.Cc = CC;
        Message.Subject = subject;
        Message.Body = body;
        Message.BodyFormat = MailFormat.Html;
        SmtpMail client = new SmtpMail ();
        client.Send (Message);
    }



3. On Send Button Event Write this Code
    
        protected void btnSendEmail_Click(object sender, EventArgs e)
        {
            try
            {
                SendMail(txtFromID.Text.Trim(), txtToEmailID.Text.Trim(), txtCcEmailID.Text.Trim(), 
                                txtSubject.Text.Trim(), txtBody.Text.Trim());
        
            }
            catch (Exception)
            {
            }
       }


4. If you have any other Other Solution please send me. 
5. If any issue please comment.
6. Thanks for Reading this Blog.

our new blog site : http://blog.hintechnology.com

Wednesday, 18 January 2012

SQL Server Reporting Configuration and Report File Upload

our new blog site : http://blog.hintechnology.com

       1)      Start à Microsoft SQL Server 2008 R2 à Configuration Tool àReporting Services Configuration      Manager àClick

       2)      It will display following window à Click Connect













3)  Now Click on IE à Type http://<SiteName>//Reports (It will displaying blank windo







Monday, 16 January 2012

Set Value in People Picker Control In SharePoint

our new blog site : http://blog.hintechnology.com

Set the Value of People Picker Control in SharePoint

Dynamically

peoplepicInitiatedBy.CommaSeparatedAccounts = Context.User.Identity.Name;

Static

peoplepicInitiatedBy.CommaSeparatedAccounts = "domain\Username";




Sunday, 15 January 2012

Split Example in C#

our new blog site : http://blog.hintechnology.com

Split Example in C# 
using System;

public class SplitExample {
    public void SplitExample() {

        string words = "This is split example. Testing User in SharePoint 2010 "+                                 "user with Domain\\username ";

        string [] split = words.Split(new Char [] {' ', ',', '.', ':', '\t' });

        foreach (string s in split) {

            if (s.Trim() != "")
                Response.Write(s);
        }
    }
}
// This will display following output://       This//       is//       split //       example//       Testing//       User//       in//       SharePoint//       2010//       user//       with//       Domain//       username
Thank you for Reading This Posts.

Monday, 9 January 2012

Activate & Deactivate infopath form using PowerShell or CMD in SharePoint


our new blog site : http://blog.hintechnology.com
Activate and Deactivate Infopath Form using Powershell or CMD in SharePoint

1. Deactivate Infopath form, from the Site Collection.
    stsadm.exe -o deactivateFormTemplate -url "http://demosite" -filename               "D:\InfoPathForms\PublishFiles\DemoSample.xsn"

2. Activate Infopath form, from the Site Collection.

    stsadm.exe -o activateFormTemplate -url "http://demosite" -filename    "D:\InfoPathForms\PublishFiles\DemoSample.xsn" 

3. Verify Infopath form 

    stsadm.exe -o verifyformtemplate -filename  "D:\InfoPathForms\PublishFiles\DemoSample.xsn"  

4. Verify Infopath form  

    stsadm.exe -o UpgradeFormTemplate -filename  "D:\InfoPathForms\PublishFiles\DemoSample.xsn" 

Thank You For Reading this Blog

Thursday, 5 January 2012

User Control in SharePoint using ASP.NET Solution

our new blog site : http://blog.hintechnology.com

Create and Deploy user Control of ASP.NET Solution in SharePoint
1.       1. Add User Control in Asp.net  Application


2.       Design your User Control with controls

3.       you can have the Design of the Form

<style type="text/css">
    .divMainJoinee
    {
        width: 260px;
        margin: 0px;
        padding: 0px;
    }
    .divnewjoin
    {
        float: left;
    }
    .divnewjoin-photo
    {
        margin: 2px;
        padding-left: 10px;
        float: left;
        width: 75px;
        height: 100px;
    }
    .divnewjoin-desc
    {
        float: left;
        width: 160px;
        height: 100px;
        padding-left: 10px;
    }
    .divnewjoin-desc > p
    {
        line-height: 20px;
        overflow: hidden;
        padding-left: 5px;
        margin: 0px;
        font-size: 10px;
        color: #294592;
        font-weight: bold;
        font-family: Verdana;
    }
    .divnewjoin-desc > p > a
    {
        font-size: 10px;
        color: #294592;
        font-weight: bold;
        font-family: Verdana;
    }
</style>
<table border="0" width="275px" cellpadding="0" class="birthbg" cellspacing="0">
    <tr>
        <td class="BDtblleft" style="font-size: 12pt; font-family: Frutiger LT 45 Light">
            <img style="height: 30px; width: 30px" src="/SiteImageLibrary/resign_employee_png.png" alt="Resigned Employee!" />Resigned
            Employee
        </td>
    </tr>
    <tr align="center">
        <td colspan="2">
            <div style="text-align: center;" class="BDtblBody">
                <asp:Repeater ID=" rptRegisnationEMP" runat="server">
                    <HeaderTemplate>
                        <div style="width: 260px; height: 140px; margin: 5px">
                            <marquee direction='up' onmouseover='this.scrollAmount=0' onmouseout='this.scrollAmount=2'
                                scrollamount="2" style='padding-top: 10px; height: 110px; padding-bottom: 10px;'>
                    <div class="divMainJoinee">
                    </HeaderTemplate>
                    <ItemTemplate>
                        <div class="divnewjoin">
                            <div class="divnewjoin-photo">
                                <img src='<%# Eval("EMP_PHOTO")%>' width="75px" height="100px" alt="Employee Name" />
                            </div>
                            <div class="divnewjoin-desc">
                                <p>
                                    <a href='<%# Eval("EMP_EMAIL", "mailto:{0}" ) %>'>
                                        <%# Eval("EMP_NAME")%>
                                    </a>
                                    <br />
                                    DEPT :
                                    <%# Eval("DEPT_NAME")%>
                                    <br />
                                    DESG :
                                    <%# Eval("DESIG_NAME")%>
                                    <br />
                                    LAST WORKING DATE :
                                    <%# Eval("EMP_LASTWORKINGDAY", "{0:dd/M/yyyy}")%>
                                </p>
                            </div>
                        </div>
                    </ItemTemplate>
                    <SeparatorTemplate>
                        <div style="clear: both;">
                            <br />
                        </div>
                    </SeparatorTemplate>
                    <FooterTemplate>
                        </div> </marquee> </div>
                    </FooterTemplate>
                </asp:Repeater>
                <asp:Label ID="lblMessage" runat="server" Text=""></asp:Label>
            </div>
        </td>
    </tr>
    <tr>
        <td style="height: 5px;">
        </td>
    </tr>
</table>

4.       The Code Behind File of the User Control Binds the Data to the Repeater Control

using System;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;

namespace  MyNameSpace
{
    public partial class EmployeeResign : System.Web.UI.UserControl
    {
        #region User Control Level Variable

        string ConnectionString = ConfigurationManager.AppSettings["ConnectionString"].ToString();
        SqlConnection objConn;
        SqlCommand objCmd;

        #endregion

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindData();
            }
        }

        #region Bind Data

        protected void BindData()
        {
            objConn = new SqlConnection(ConnectionString);

            try
            {
                objConn.Open();

                objCmd = new SqlCommand("GETEMPRESIGNATION", objConn);

                DataTable objtblResignatioEmp = new DataTable();
                SqlDataAdapter objadpNewJoinee = new SqlDataAdapter(objCmd);
                objadpNewJoinee.Fill(objtblResignatioEmp);

                if (objtblNewJoinee.Rows.Count > 0)
                {
                    rptRegisnationEMP.DataSource = objtblResignatioEmp
                    rptRegisnationEMP.DataBind();
                }
                else
                {
                    lblMessage.Text = "No Record Found";
                }
            }
            catch (Exception es)
            {
                lblMessage.Text = es.Message;
            }
            finally
            {
                objConn.Close();
            }
        }
        #endregion
    }
}

5.       Build the Solution
6.       Create User Control folder in the IIS Directory of the SharePoint Site.

7.       Add your user control file in the “UserControls” files which you have recently created.



8.       Deploy the Asp.NET DLL of the Solution in the GAC, and Add in the Web Config files of the sharepoint Site.
<SafeControl Assembly="Put_Your_Assembly_Details", Version=1.0.0.0, Culture=neutral, PublicKeyToken=e28cff1753813c3e" Namespace="Your_Solution_Namespace" TypeName="*" Safe="True" />  
9.       Now Edit the SharePoint Page, where you want to add this user control, SMARTPART is one of the free Web Parts through which we can Add your usercontrol Directly so ADD SMARTPART Web Part in your Farm Solution, and Add the Smart Part Web Part in the Editing Page.



10.   Edit the Smart Page Web Part and Select the Your UserControl Name from the Drop Down List.



 Thank you for Reading Post.

Tuesday, 3 January 2012

Web Part Page Property in SharePoint

our new blog site : http://blog.hintechnology.com
Create Custom SharePoint Web Part Property.
In this example i have created custom page viewer Web Part
1. I have created  a Visual Web Part, and have added the following in this Web Part Pages.

   a) Add the following Code in the WebPart.cs File of the Visual Web Part as Displayed below

[ToolboxItemAttribute(false)]
    public class CustomPageViewerWebPart : WebPart
    {
        // Visual Studio might automatically update this path when you change the Visual Web Part project item.
        private const string _ascxPath = @"~/_CONTROLTEMPLATES/CustomPageViewer/CustomPageViewerWebPart/CustomPageViewerWebPartUserControl.ascx";

        [WebBrowsable(true),
         Category("Miscellaneous"),
         Personalizable(PersonalizationScope.Shared),
         WebDisplayName("Enter URL")]
        public string PageURL { get; set; }

        [WebBrowsable(true),
         Category("Miscellaneous"),
         Personalizable(PersonalizationScope.Shared),
         WebDisplayName("PageHeight")]
        public string PageHeight { get; set; }

        [WebBrowsable(true),
         Category("Miscellaneous"),
         Personalizable(PersonalizationScope.Shared),
         WebDisplayName("PageWidth")]
        public string PageWidth { get; set; }


        protected override void CreateChildControls()
        {
            CustomPageViewerWebPartUserControl control = Page.LoadControl(_ascxPath) as      CustomPageViewerWebPartUserControl;
            Controls.Add(control);

            if (control != null)
                control.CustomPVWebPart = this;
            Controls.Add(control);
        }
    }



  b) Add the Following Design in the User Control Page


<div id="divIframe" visible="false" runat="server">
    <iframe src="http://www.google.com" width="100%" height="100%" runat="server" id="customiframe">
    </iframe>
</div>
<div id="divMessage" visible="true" runat="server">
    <asp:Label ID="lblMessage" runat="server" Text=""> </asp:Label>
</div>



    c) Add the following code in the Code Behind file of the Web Part 

   

    public partial class CustomPageViewerWebPartUserControl : UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }

        public CustomPageViewerWebPart CustomPVWebPart { get; set; }

        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);
            try
            {
                if (this.CustomPVWebPart != null && this.CustomPVWebPart.PageURL != null
                    && this.CustomPVWebPart.PageHeight != null && this.CustomPVWebPart.PageWidth != null)
                {
                    divIframe.Visible = true;
                    divMessage.Visible = false;
                    customiframe.Attributes.Add("src", this.CustomPVWebPart.PageURL);
                    customiframe.Attributes.Add("width", this.CustomPVWebPart.PageWidth);
                    customiframe.Attributes.Add("height", this.CustomPVWebPart.PageHeight);
                }
                else
                {
                    divIframe.Visible = false;
                    divMessage.Visible = true;
                    lblMessage.Text = "no page is referred";
                }
            }
            catch (Exception ex)
            {
                divIframe.Visible = false;
                divMessage.Visible = true;
                lblMessage.Text = ex.Message;
            }
        }
    }



OutPut



Thanks for Reading this Blog