Thursday 24 October 2013

Error occurred in deployment step 'Install app for SharePoint' AppMng.svc could not be activated in sharepoint 2013


Problem: Error    1    Error occurred in deployment step 'Install app for SharePoint': The requested service,
'http://vijay:32843/a89a67b860dc473a9055912c37c4c423/AppMng.svc' could not be activated. See the server's diagnostic trace logs for more information.
        0    0    MyFirstApp

 Reason: Open the Url  http://vijay:32843/a89a67b860dc473a9055912c37c4c423/AppMng.svc so you come to know the issue because free memory is less than a total memory.

Solution: To Overcome this we need to restart the service of "SPSearchHostController" Or stop the some of the service running for sharepoint 2013.

Tuesday 9 July 2013

Programmatically Checking Regular Expression Condition for DateTime Format(MM/DD/YYYY)

 <asp:TextBox ID="textbox1"  runat="server"/>

 <asp:Button ID="btnmatch" runat="server" Text="Result"
                        onclick="btnmatch_Click" />

 protected void btnCalculate_Click(object sender, EventArgs e)
    {
    string date = textbox1.text;
     Regex regex = new Regex(@"^(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d$");
        Match match = regex.Match(date);
        if (match.Success)
            {
           MessageBox.Show("Matched Regex condition");
            }
       else
          {
             MessageBox.Show("Does not Matched Regex condition");
           }
   }

Monday 11 February 2013

Asp.net MVC View Page with HTML Tag Instead of HTML Helper

Let see how to create a MVC View Page with an normal HTML tag instead of Html Helper

Step 1: Create  a Database in Sql Server or Sql Express

Database Name: Contact Details
Table Name: Contact
Create Column:

       1.Id - Set Id to auto-increment
       2.Name - string
       3.Location - String

Step 2: Create a Asp.net MVC Application 4 Named  "Output"

1. Web.config - Add database connection

<connectionStrings> <add name="ContactDBContext" connectionString="Data Source=serverName;Initial Catalog=Contact Details; ID=sa;Password=**** providerName="System.Data.SqlClient" /> </connectionStrings>

2. Model:  Add ContactModel

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Entity;

namespace Output.Models
{
    public class ContactModel
    {
       
        public int ID
        { get; set; }
        public string Name
        { get; set; }
        public string Location
        { get; set; }
       
    }
    public class ContactDBContext : DbContext
    {
        public DbSet<ContactModel> Contact { get; set; }
    }
}

3.Controller: Add ContactController

In Controller - Add view Name "Contact" and Call "ContactModel" and Make View as "Empty"

and add the folling content

<!DOCTYPE html>

<html>
<head runat="server">
    <meta name="viewport" content="width=device-width" />
    <title>Index</title>
</head>
<body>
    <div>
        <form action="DisplayContact" method="post">

Name :- <input type="text" name="Name" /><br />
Location :-<input type="text" name="Location" /><br />
<input type="submit" value="Submit Contact Details" />
</form>
    </div>
</body>
</html>


4. In the ContactController add the following content


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Output.Models;

namespace Output.Controllers
{
    public class ContactController : Controller
    {
        ContactDBContext ContactDB = new ContactDBContext();
       
        //
        // GET: /Contact/

        public ActionResult Index()
        {
            return View();
        }

        public ActionResult DisplayContact(string Name,string Location)
        {
            ContactModel obj = new ContactModel();
            obj.Name = Name;
            obj.Location = Location;
            ContactDB.Contact.Add(obj);
            ContactDB.SaveChanges();
            return RedirectToAction("Index");
           }
    }
}


That's it
Enjoy Coding....