Click here to Skip to main content
15,899,825 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
<pre lang="C#">using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Script.Serialization;
using System.Collections.Specialized;

namespace XeroConsultingWebApp
{
    /// &lt;summary&gt;
    /// Summary description for JQGridHandler
    /// &lt;/summary&gt;
    public class JQGridHandler : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            int userID = 0;
            //context.Response.ContentType = &quot;text/plain&quot;;
            //context.Response.Write(&quot;Hello World&quot;);
            System.Collections.Specialized.NameValueCollection forms = context.Request.Form;
            string strOperation = forms.Get(&quot;oper&quot;);
            RsHunterDBEntities ctx = new RsHunterDBEntities();
            var userCollection = ctx.Users.Where(x =&gt; x.UserID == userID).ToList();
            string strResponse = String.Empty;

            if (strOperation == null)
            {
                //oper = null which means its first load.
                var jsonSerializer = new JavaScriptSerializer();
               context.Response.Write(jsonSerializer.Serialize(userCollection.AsQueryable&lt;User&gt;().ToList&lt;User&gt;()));
            }
            else if(strOperation == &quot;del&quot;)
            {
                using (var ctx2 = new RsHunterDBEntities())
                {
                    var query = ctx.Users.Where(x =&gt; x.UserID == userID).First();
                    ctx.Users.Remove(query);
                    ctx.SaveChanges();
                }
                strResponse = &quot;User Record Successfully Removed&quot;;
                context.Response.Write(strResponse);
            }
            else 
            {
                string strOut = String.Empty;

                context.Response.Write(strOut);
            }

        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
        public void AddEdit(NameValueCollection forms, RsHunterDBEntities myContext, out string strResponse, int userID) 
        {
            string strOperation = forms.Get(&quot;oper&quot;);
            string strUserId = string.Empty;
            if (strOperation == &quot;add&quot;)
            {
                strUserId = forms.Get(&quot;UserID&quot;).ToString();
            }
            else if(strOperation == &quot;edit&quot;)
            {
                var result = myContext.Users.AsQueryable&lt;User&gt;().Select(x =&gt; x.UserID).Max();
                
                strUserId = result.ToString();
            }
            string strFirstName = forms.Get(&quot;FirstName&quot;);
            string strLastName = forms.Get(&quot;LastName&quot;);
            string strIsActive = forms.Get(&quot;IsActive&quot;).ToString();
            string strDepartment = forms.Get(&quot;Department&quot;);
            string strEmail = forms.Get(&quot;Email&quot;);
            string strIsSuperAdmin = forms.Get(&quot;IsSuperAdmin&quot;).ToString();
            string strJobRole = forms.Get(&quot;JobRole&quot;);
            string strUsername = forms.Get(&quot;Username&quot;);

            var queryUser = myContext.Users.Where(x =&gt; x.UserID == userID).First();
            queryUser.UserID = Convert.ToInt32(strUserId);
            queryUser.FirstName = strFirstName;
            queryUser.LastName = strLastName;
            queryUser.IsActive = Convert.ToBoolean(strIsActive);
            queryUser.Department = strDepartment;
            queryUser.Email = strEmail;
            queryUser.IsSuperAdmin = Convert.ToBoolean(strIsSuperAdmin);
            queryUser.JobRole = strJobRole;
            queryUser.UserName = strUsername;
            myContext.Users.Add(queryUser);
            strResponse = &quot;Record Successfully Updated&quot;;
            
            
        }
    }
}</pre>

======================================================================================
<pre lang="HTML">&lt;%@ Master Language=&quot;C#&quot; AutoEventWireup=&quot;true&quot; CodeBehind=&quot;AlternateMaster.master.cs&quot; Inherits=&quot;XeroConsultingWebApp.AlternateMaster&quot; %&gt;

&lt;!DOCTYPE html&gt;


&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head runat=&quot;server&quot;&gt;
    &lt;title&gt;&lt;/title&gt;
    &lt;asp:ContentPlaceHolder ID=&quot;head&quot; runat=&quot;server&quot;&gt;
    &lt;/asp:ContentPlaceHolder&gt;
    &lt;link href=&quot;~/favicon.ico&quot; rel=&quot;shortcut icon&quot; type=&quot;image/x-icon&quot; /&gt;
     &lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;Content/bootstrap.min.css&quot; /&gt;
    &lt;!--&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;Content/bootstrap.css&quot; /&gt;--&gt;
    &lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;Content/default.css&quot; /&gt;
    &lt;link rel=&quot;stylesheet&quot; href=&quot;Content/font-awesome/css/font-awesome.min.css&quot;/&gt;
    &lt;link rel=&quot;stylesheet&quot; href=&quot;Content/accordion-menu.css&quot; /&gt;

    &lt;script src=&quot;JQGridReq/jquery-1.9.0.min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
    &lt;link href=&quot;JQGridReq/jquery-ui-1.9.2.custom.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;
    &lt;script src=&quot;JQGridReq/jquery.jqGrid.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
    &lt;link href=&quot;JQGridReq/ui.jqgrid.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;
    &lt;script src=&quot;JQGridReq/grid.locale-en.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;

    &lt;script type=&quot;text/javascript&quot; src=&quot;/scripts/jquery-1.10.2.min.js&quot;&gt;&lt;/script&gt;
    &lt;script type=&quot;text/javascript&quot; src=&quot;/Scripts/accordion-menu.js&quot;&gt;&lt;/script&gt;
    &lt;script type=&quot;text/javascript&quot; src=&quot;Scripts/checkAll.js&quot;&gt;&lt;/script&gt;
    &lt;%--&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;Content/ui.jqgrid.css&quot; /&gt;--%&gt;
    
   
    
    
    
&lt;/head&gt;
&lt;body&gt;
    &lt;form runat=&quot;server&quot;&gt;
        &lt;div id=&quot;header&quot;&gt;
  &lt;div id=&quot;logo&quot;&gt;&lt;a href=&quot;Default.aspx&quot;&gt;&lt;img runat=&quot;server&quot; src=&quot;images/logo.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
  &lt;div id=&quot;topnav&quot;&gt;
      
  
      
          &lt;asp:Panel ID=&quot;Panel1&quot; runat=&quot;server&quot;&gt; 
              &lt;asp:LoginView ID=&quot;LoginView1&quot; runat=&quot;server&quot;&gt; 
                  &lt;AnonymousTemplate&gt;
                      &lt;asp:Panel ID=&quot;CtrlAnonymousPanel&quot; runat=&quot;server&quot;&gt;
                           &lt;ul class=&quot;nav navbar-nav navbar-right&quot;&gt;
                                &lt;li&gt;&lt;a runat=&quot;server&quot; href=&quot;~/Account/Register.aspx&quot;&gt;Register&lt;/a&gt;&lt;/li&gt;
                                &lt;li&gt;&lt;a runat=&quot;server&quot; href=&quot;~/Account/Login.aspx&quot;&gt;Log in&lt;/a&gt;&lt;/li&gt;
                                &lt;li&gt;&lt;a runat=&quot;server&quot; href=&quot;~/Account/ForgotPassword.aspx&quot;&gt;Forgot Password&lt;/a&gt;&lt;/li&gt;
                            &lt;/ul&gt;
                      &lt;/asp:Panel&gt;
                  &lt;/AnonymousTemplate&gt;
                  &lt;LoggedInTemplate&gt;
                      &lt;asp:Panel ID=&quot;CtrlLoggedInPanel&quot; runat=&quot;server&quot;&gt;
                          &lt;ul class=&quot;nav navbar-nav navbar-right&quot;&gt;
                                &lt;li&gt;&lt;a runat=&quot;server&quot; href=&quot;~/Account/Manage&quot; title=&quot;Manage your account&quot;&gt;Hello, &lt;%: Context.User.Identity.Name  %&gt; !&lt;/a&gt;&lt;/li&gt;
                                &lt;li&gt;
                                    &lt;asp:LoginStatus runat=&quot;server&quot; LogoutAction=&quot;Redirect&quot; LogoutText=&quot;Log off&quot; LogoutPageUrl=&quot;~/&quot; OnLoggingOut=&quot;Unnamed_LoggingOut&quot; /&gt;
                                &lt;/li&gt;
                            &lt;/ul&gt;
                      &lt;/asp:Panel&gt;
                  &lt;/LoggedInTemplate&gt;&lt;/asp:LoginView&gt; 

          &lt;/asp:Panel&gt; 
              
       
   
       
  &lt;/div&gt;
&lt;/div&gt;
 &lt;div id=&quot;banner&quot;&gt;&lt;img runat=&quot;server&quot; src=&quot;images/banner.jpg&quot; /&gt;

 &lt;/div&gt;
    &lt;asp:ContentPlaceHolder ID=&quot;AlternateMasterContent&quot; runat=&quot;server&quot;&gt;
                     
   &lt;/asp:ContentPlaceHolder&gt;
         
        &lt;div class=&quot;clearfix&quot;&gt;&lt;/div&gt;
        &lt;div id=&quot;container&quot;&gt;
    &lt;div class=&quot;row&quot;&gt;
        &lt;div class=&quot;col-md-4&quot;&gt;
            &lt;i class=&quot;fa fa-user fa-4x&quot; &gt;&lt;/i&gt; &lt;h3&gt;Competency Framework&lt;/h3&gt;
                    &lt;p&gt;
                        ASP.NET Web Forms lets you build dynamic websites using a familiar drag-and-drop, event-driven model.
                        A design surface and hundreds of controls and components let you rapidly build sophisticated, powerful UI-driven sites with data access.
                    &lt;/p&gt;
            &lt;div id=&quot;btn&quot;&gt;
                  &lt;a class=&quot;btn btn-primary btn-large&quot; href=&quot;#&quot;&gt;Read More&lt;/a&gt;
            &lt;/div&gt;
          &lt;/div&gt;
        &lt;div class=&quot;col-md-4&quot;&gt;
            &lt;i class=&quot;fa fa-windows fa-4x&quot; &gt;&lt;/i&gt; &lt;h3&gt;Competency Catalog&lt;/h3&gt;
                    &lt;p&gt;
                        ASP.NET Web Forms lets you build dynamic websites using a familiar drag-and-drop, event-driven model.
                        A design surface and hundreds of controls and components let you rapidly build sophisticated, powerful UI-driven sites with data access.
                    &lt;/p&gt;
            &lt;div id=&quot;btn1&quot;&gt;
                  &lt;a class=&quot;btn btn-primary btn-large&quot; href=&quot;#&quot;&gt;Read More&lt;/a&gt;
            &lt;/div&gt;
          &lt;/div&gt;
        &lt;div class=&quot;col-md-4&quot;&gt;
            &lt;i class=&quot;fa fa-arrow-circle-o-down fa-4x&quot; &gt;&lt;/i&gt; &lt;h3&gt;Competency Assessment&lt;/h3&gt;
                    &lt;p&gt;
                        ASP.NET Web Forms lets you build dynamic websites using a familiar drag-and-drop, event-driven model.
                        A design surface and hundreds of controls and components let you rapidly build sophisticated, powerful UI-driven sites with data access.
                    &lt;/p&gt;
            &lt;div id=&quot;btn2&quot;&gt;
                  &lt;a class=&quot;btn btn-primary btn-large&quot; href=&quot;#&quot;&gt;Read More&lt;/a&gt;
            &lt;/div&gt;
          &lt;/div&gt;

    &lt;/div&gt;

    
&lt;/div&gt;
    
     
       
   &lt;div id=&quot;footer&quot;&gt;
       &lt;p id=&quot;datePicker&quot;&gt;&amp;copy; &lt;%: DateTime.Now.Year %&gt; - Xero Consulting&lt;/p&gt;
   &lt;/div&gt;
    &lt;/form&gt;


&lt;/body&gt;
&lt;/html&gt;</pre>


What I have tried:

I tried using guidelines i saw from an article by K K Kodoth he used mongoDB or so but i am using ms sql.
Posted
Comments
Suvendu Shekhar Giri 17-Feb-16 2:11am    
What is the problem with the shared code?
Are you getting any exception?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900