DotNet Solution

  • Home
  • Asp.net
    • Controls
    • DataControl
    • Ajax
  • Web Design
    • Html
    • Css
    • Java Script
  • Sql
    • Queries
    • Function
    • Stored Procedures
  • MVC
    • OverView
    • Create First Application
  • BootStrap
    • Collapse Function

Saturday, 17 December 2016

Create First MVC Application

  Unknown       21:28       No comments    

How to create MVC First simple application

It is very easy to make application in mvc follow some steps and create first application

STEP 1 - Click on Start menu and  Open Visual studio.


STEP 2 - Open View folder click Home folder and click index page run and see on  home this is by default in Poject inbuilt page so see esaly. And if we create new Controller then see right click on controller folder and add new controller.


STEP 3 - Open A window and choose Empty controller and click on add button->  open next we give name of the controller.
Ex. we Give name Simplecontroller and click add button. In application add controller like.


In This index is by default create action.
  public class SimpleController : Controller
Controller is base class inherit this controller.
STEP 4 -  Add on view Right click on Index method ->click on  ->Add View. open new window.



Give name view and if we add layout page (master page then choose in drop down if no then leave empty) and click Add button 
Ex. in this View index name and create page in View folder-> simple folder->Index page. now we ready to code.




Save yhis content and run this page.
Output-

Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+

Thursday, 15 December 2016

Open First Application in MVC

  Unknown       08:35       CreateApplication       No comments    


How To Create First Application in MVC.Follows Some Steps-

   STEP 1. Firstly Go Start menu in Computer And Click on Installed Visual studio.
   Ex.


Open This Window after processing next  window open like-
Ex.


STEP 2.  Create  new application select new project or We Also Select in file new project. 
                Click on  a new project.


STEP 3.  Choose Your Project Save Location and Select Asp.net web Application and click on button.Next Open window.


Select MVC and Click OK button Then open Application We See.


We see folder Model ,View and Controller. 
 Model   -  Right Click on Model folder and Add New Class .We Declare Property And Data type 
                  Which is use in Project.
Controller - Make Function and use Model classes in Controller and Add view easly through                                   controller  action .Coding Part Write in Controller
View -   Use  Model class and Create design part in view.
Content -  This folder contain all CSS regarding Project Releted.
Script -  This folder contain All JS we use in our Project
WebConfig - Connection String Write in Web Config.
Global - We define route of application page



Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+

Saturday, 10 December 2016

Javascript Regular Expression Email Validate

  Unknown       21:19       No comments    


Validate Email using Regular Expression In JavaScript-

1. Create Input type Text box and and onclick cal  checkemail function of Javascriptusing .
2. Define Function in Script with regex expression .

<script>
function checkEmail()
{
      email = $('#txtEmail');
      filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
   if (filter.test(email.value)) {
      //  valid Email
          return true;
            }
   else
          {return false;}
  }
</script>
<body>
      <input id="txtEmail" type="text" onclick="checkEmail();" />
</body>
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+

Thursday, 8 December 2016

Email Validation In JavaScript

  Unknown       10:07       javascript       No comments    


We use Validation for Email  in Javascript
like in above example

<!DOCTYPE html>
<html>
<head>
<script>
function validateForm() {
    var x = document.forms["myForm"]["email"].value;
    var atpos = x.indexOf("@");
    var dotpos = x.lastIndexOf(".");
    if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length) {
        alert("Not a valid e-mail address");
        return false;
    }
else
    {
         alert("Valid e-mail address");}
     }
}
</script>
</head>

<body>
<form name="myForm"  onsubmit="return validateForm();" >
Enter Email: <input type="text" name="email">
<input type="submit" value="Submit">
</form>
</body>

</html>


OutPut
Enter Email:
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+

Friday, 2 December 2016

Collapse Function Use in Bootstrap.

  Unknown       11:51       AllFunction       No comments    


Defination 

1.  Collapse Means suddenly fall down.
2.  Just add data-toggle="collapse" and a data-target to element to automatically assign control of a collapsible element. The data-target attribute accepts a CSS selector to apply the collapse to. Be sure to add the class collapse to the collapsible element. If you'd like it to default open, add the additional class in.
3. Collpse means expand area just like toggle.
4. We Want to Toggle like show and hide any paragraph On Click.
Example
<html>
<head>
   <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"></link>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
  <h3>
Collapse</h3>
<button class="btn btn-info" data-target="#test" data-toggle="collapse" type="button">Simple collapsible</button>
  <div class="collapse" id="test">
   Hello This is collapse Function Use
  </div>
</div>
</body>
</html>


OutPut
Please Click on Button and show Expand Paragraph


Collapse

Hello This is collapse Function Use

The Collapse   Plugin Classes
Class  Discription
.collapse :   Hides the content
.collapse in : Show the content
.collapsing :Added when the transition starts, and removed when it finishes
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+

Tuesday, 29 November 2016

Install Visual Stdio Step by Step Process

  Unknown       09:59       over view       No comments    


How to install visual studio 2015 Step by Step Process like =>

Step (1) : Once downloading is complete, run the installer. The following dialog will be displayed.


Step (2): Click the ‘Install’ button and it will start the installation process.

Once the installation process is completed successfully, you will see the following dialog

Step (3): Close this dialog and restart your computer if required.

Step (4): Open Visual Studio from the Start Menu, which will open the following dialog. It will take a while for the first time only for preparation.


Once all is done, you will see the main window of Visual Studio as shown in the following screenshot.
You are now ready to start your application.
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+

Friday, 25 November 2016

Auto Increment Id in Sql Server

  Unknown       12:13       Queries       No comments    

SQL server identity column values use in table

Steps-Firstly Open-> Sql Server Create Table -> First Field Like ID Usually Autoincrement=>
Table create then=>insert data in table=> then Select data show increment id.

The following SQL statement defines the "ID" column to be an auto-increment primary key field in the "Category" table (Given Category is Table Name and CategoryId And  CategoryName are Field  in Table

         Create table Category
             (
                   CategoryId INT IDENTITY(1,1) Primary Key,
                   CategoryName NVARCHAR(100)     
             )

  We use IDENTITY(1,1) in Table .
Where the 1,1 is the starting number is 1 and increment  by 1 that's the resion We use Identity(1,1)


In the example above, the starting value for IDENTITY is 1, and it will increment by 1 for each new record.
Exp. To specify that the "ID" column should start at value 10 and increment by 5, change it to IDENTITY(10,5).

Result-



   In This Following Image CategoryId Is Auto Increment And Id id Start with 1 and It Will 
    Increment By 1
    
  Use This Steps In Result-

  1. Create Table With Create Query.

  2. Insert Data With Insert Query.

  3.  Show Table Data Through Select Query in Sql Server.




Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+

Thursday, 24 November 2016

MVC Framework Architecture

  Unknown       09:38       OverView       No comments    

MVC Flow-

MVC application takes place when certain request comes from the client. The diagram below shows the flow:

Flow Steps

  • 1.  The client browser sends request to the MVC Application.
  • 2.  Global.ascx receives this request and performs routing based on the URL of 3. incoming request using the RouteTable, RouteData, UrlRoutingModule and MvcRouteHandler objects.
  • 3.  This routing operation calls the appropriate controller and executes it using the IControllerFactory object and MvcHandler object's Execute method.
  • 4.  The Controller processes the data using Model and invokes the appropriate method using ControllerActionInvoker object
  • 5.  The processed Model is then passed to the View which in turn renders the final output.
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+

Wednesday, 23 November 2016

The Evolution of MVC

  Unknown       11:31       OverView       No comments    

Microsoft had introduced ASP.NET MVC in .Net 3.5,since then lots of new features have been added.The following table list brief history of ASP.NET MVC.



ASP.Net MVC 5.2 [Current]

1.  MVC Version -   Asp.Net MVC 5.2
2.  Release date -   28 August 2014
3.  Visual Studio - VS 2013
4.  .Net Version -  .Net 4.5 framework
5.   Features -    
                       1.   Attribute based routing
                       2.  Minor update of Asp.Net MVC5
                        3.  Asp.Net MVC 5 bug fixed

ASP.Net MVC 5

1.  MVC Version -   Asp.Net MVC 5.0
2.  Release date -   17 October 2013
3.  Visual Studio - VS 2013
4.  .Net Version -  .Net 4.5 Framework.
5.   Features -    
                       1.  Authentication filters
                       2.  One Asp.Net.
                       3.  Asp.Net Identity.
                       4.  Bootstrap support in MVC template.
                      5.  New Asp.Net scaffolding.
                       6. Authentication filters.
                       7.  Minor update of Asp.Net MVC5.
                       8.Asp.Net MVC 5 bug fixed.

ASP.Net MVC 4

1.  MVC Version -   Asp.Net MVC 4.0
2.  Release date -   15 August 2012 .
3.  Visual Studio - VS 2010 SP1 and VS 2012.
4.  .Net Version -  .Net 4.0/.Net 4.5 Framework.
5.   Features -    
                       1.  Add Window Azure SDK support feature.
                       2.  Bundling and Minification.
                       3.  Introduce Asp.Net Web API.
                       4.  Mobile Project Template using jquery mobile.
                      5.  Display Modes.

 ASP.Net MVC 3

1.  MVC Version -   Asp.Net MVC 3.0
2.  Release date -   13 January 2010
3.  Visual Studio - VS 2013
4.  .Net Version -  .Net 4.0 Framework
5.   Features -    
                       1.  Razor view engine.
                       2.  ViewBag dynamic property.
                       3.  Entity framework Code First.
                       4.  Global action filters.
                      5.  Dependency resolver for IoC.
                       6.  Remote validation.
                       7.  Compare Attribute.

ASP.Net MVC 2

1.  MVC Version -   Asp.Net MVC 2.0
2.  Release date -   10 March 2010
3.  Visual Studio - VS 2008
4.  .Net Version -  .Net 3.5/.Net 4.0 Framework
5.   Features -    
                       1.  Client side validation.
                       2.  Scaffolding.
                       3.  Asynchronous controller.
                       4.  Area for creating module based application.
                      5.  Lambda expression based Html helpers.
                       6.  DataAnnotation attribute
                       7.  Custom template Helper

ASP.Net MVC 1

1.  MVC Version -   Asp.Net MVC 1.0
2.  Release date -   13 March 2009
3.  Visual Studio - VS 2008
4.  .Net Version -  .Net 3.5 Framework
5.   Features -    
                       1.  MVC architecture pattern and web form engine
                       2.  Auto binding
                       3.  Ajax Helpers
                       4.  Html Helpers
                      5.  Routing
                       6.  Unit testing
                   



Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+

Sunday, 20 November 2016

MVC vs ASP.NET

  Unknown       18:26       OverView       No comments    

There are various positive points to Using MVC

1.  TDD support out of the box as most of the design is based on interfaces.
2.  SEO friendly URL by design (though now this is possible in ASP.NET 4 as well)
3.  No ViewState (this may seem a bit of moving backward to some), but overall a good design    decision.
4.  Clean View Markup (no additional HTML emitted)
5.  100% extensible.  You can add your own controller with IOC, switch view engines at will, control model binding at wish etc.
6.   Rich UI support (possible through client side JS libraries like jQuery UI and others).  Telerik has released some controls for MVC which includes Grid control as well (which are merely HTMLHelpers)
7.  Session, JS, Ajax works.  Validation is even more powerful with DataAnnotations and jquery.
8.  Is MVC faster?  Yes by default because of lack of viewstate and clean markup.  But performance is subject and MVC by design is more performant that traditional ASP.NET webforms (though webforms can be made as fast as required.
9.  Out of the box support for mitigating antiforgery attacks and XSS vulnerability (though asp.net does has this to some extent)
10.  Out of the box minimal IOC support.
11.  Full control over rendered HTML
12.  Pluggable architecture


***ASP.NET WebForms developers migrating to ASP.NET MVC initially feel a little uncomfortable because they are unable to find many key features that were available in WebForms approach. There are many questions comes to their minds like below:

1. Web is still stateless but where is the Viewstate?
2. Where is that Code behind file?
3. What is that Razor syntax? Why I need it?
4. Where to find Page_Load method? that is used to put code for almost every page.
4. What about Binding and Rich Server Controls? Where these controls gone?
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+

Friday, 18 November 2016

Main Advantage Of MVC

  Unknown       11:28       OverView       No comments    

There Are Many Advantage of MVC(Model view & Controller)
1.  Faster development process.
2.  Easier to manage complexity (divide and conquer).
3.  It does not use server forms and view state.
4.  Front Controller pattern (rich routing).
5.  Better support for test-driven development.
6.  Ideal for distributed and large teams .
7.  High degree of control over the application behavior.
8.  Enables the full control over the rendered HTML.
9.  Provides clean separation of concerns(SoC).
10.  Enables Test Driven Development (TDD).
11.  Easy integration with JavaScript frameworks.
12.  Following the design of stateless nature of the web.
13.  RESTful urls that enables SEO.
14.  No ViewState and PostBack events.

Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+

Wednesday, 16 November 2016

MVC OverView

  Unknown       08:54       OverView       No comments    

Introduction

The Model-View-Controller (MVC) architectural pattern separates an application into three main components: the model, the view, and the controller. The ASP.NET MVC framework provides an alternative to the ASP.NET Web Forms pattern for creating Web applications. The ASP.NET MVC framework is a lightweight, highly estable presentation framework that (as with Web Forms-based applications) is integrated with existing ASP.NET features, such as master pages and membership-based authentication. The MVC framework is defined in the System.Web.Mvc assembly.


Model:   
                 Model represents shape of the data and business logic.It maintains the data of The application. Model objects retrieve and store model state in a database.
                                   Note -     Model is a data and business logic.
View:  
              View is a user interface. View display data using model to the user and also enables them to   modify  the data.
                                   Note -  View is a User Interface.
Controller:
                       Controller handles the user request. Typically, user interact with View, which in-tern raises appropriate URL request, this request will be handled by a controller. The controller renders the appropriate view with the model data as a response.

                                 Note -   Controller is a request handler.



MVC Architecture

The following figure illustrates the flow of the user's request in ASP.NET MVC  See Above-.
                                             Request/Response in MVC Architecture                                      

As per the above figure, when the user enters a URL in the browser, it goes to the server and calls appropriate controller. Then, the Controller uses the appropriate View and Model and creates the
the response and sends it back to the user.


Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+

Tuesday, 8 November 2016

Get Random Rows in SqlServer

  Unknown       12:03       Queries       No comments    

How To Get  Random  ROWS in  Table  Using Sql Server


Step 1- 
             Open Sql Server and Create Table like in Ex.

Ex.

Step 2-
              We want to  fetch Unique Randomly Rows and values in table  Then use query like

Syntax-   SELECT TOP 2 * FROM tbl_Randomvalues ORDER BY NEWID() 

Result


The key here is the NEWID function, which generates a globally unique identifier (GUID) in memory for each row.By definition, the GUID is unique and fairly random; so, when you sort by that GUID with the ORDER BY clause, you get a random ordering of the rows in the table.
So finaly we get Unique and Random rows by using this query. We use Top 2 its use to only Top 2 result in table.

SELECT TOP 2 * FROM tbl_Randomvalues ORDER BY NEWID() 



Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+

Wednesday, 20 July 2016

Numeric Value Validation Through JavaScript

  Unknown       06:15       Js       No comments    

Validate Only Numeric Value Enter In TextBox Using JavaScript function
Firstly Write Java Script Function in <head tag> in Asp.Net
After That Call Function <OnKeyPress > on TextBox
Ex.
<head>
<script type="text/javascript">
   var specialKeys = new Array();
   specialKeys.push(8); //Backspace
        function IsNumeric(e)
         {
                  var keyCode = e.which ? e.which : e.keyCode
                   var ret = ((keyCode >= 48 && keyCode <= 57) || specialKeys.indexOf(keyCode) != -1);
                   document.getElementById("error").style.display = ret ? "none" : "inline";
                    return ret;
          }
</script>
</head>

Call On TextBox
ex.
<table>
<tr>
<td> Employee Salary<td>
<td>:</td>
<td>
  <asp:TextBox ID="tbnEmpSalary" runat="server" MaxLength="12" onkeypress="return IsNumeric(event)"></asp:TextBox>
     <span id="error">* Input digits (0 - 9)</span>
</td>
</tr>
</table>

OutPut
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+

Saturday, 16 July 2016

Split Function in Sql Serever

  Unknown       03:31       No comments    

We Use This Function and Get Values .Values split With Comma Operator and Get Split Values

Ex.
CREATE function [dbo].[SplitPra]       
(       
 @list varchar(8000)       
)       
returns @t table        
(       
 Word varchar(MAX) not null,       
 Position int identity(1,1) not null       
)       
as begin       
  declare        
    @pos int,       
    @lpos int,       
    @item varchar(100),       
    @ignore varchar(100),       
    @dl int,       
    @a1 int,       
    @a2 int,       
    @z1 int,       
    @z2 int,       
    @n1 int,       
    @n2 int,       
 @n3 int,      
 @n4 int,     
 @n5 int,      
    @c varchar(1),       
    @a smallint       
  select        
    @a1 = ascii('a'),       
    @a2 = ascii('A'),       
    @z1 = ascii('z'),       
    @z2 = ascii('Z'),       
    @n1 = ascii('0'),       
    @n2 = ascii('9'),       
 @n3 = ascii('.'),     
 @n4 = ascii('-'),     
 @n5 = ascii(' ')     
  set @ignore = '''"'       
  set @pos = 1       
  set @dl = datalength(@list)       
  set @lpos = 1       
  set @item = ''       
  while (@pos <= @dl) begin       
    set @c = substring(@list, @pos, 1)       
    if (@ignore not like '%' + @c + '%') begin       
      set @a = ascii(@c)       
      if ((@a >= @a1) and (@a <= @z1))         
        or ((@a >= @a2) and (@a <= @z2))       
        or ((@a >= @n1) and (@a <= @n2))       
  or (@a=@n3) or (@a=@n4) or (@a=@n5)      
      begin       
        set @item = @item + @c       
      end else if (@item > '') begin       
        insert into @t values (@item)       
        set @item = ''       
      end       
    end        
    set @pos = @pos + 1       
  end       
  if (@item > '') begin       
    insert into @t values (@item)       
  end       
  return       
end


Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+

Values Enter With SplitFunction in Sql Server

  Unknown       03:28       StoredProcedures       No comments    


Basically We Use Split Function Thorugh Commma Sepertaed string value with  Comma  Means One Then more value through split function Enter and Fatch Single Values in A new Record

Ex.
Create procedure CommaSeperate                    
@st1 nvarchar(max),
str2 nvarchar(max)                 
AS                             
DECLARE    @i INT,@totaltran INT ,@st11 NVARCHAR(50),@str22 NVARCHAR(50)                   
SELECT @totaltran=dbo.fnCountOccurences(',',@str22)                             
SET @i=1                             
WHILE @i<=@totaltran                           
 BEGIN                
   SELECT @st11=a.Word,@str22=b.Word  FROM dbo.splitpra(@st1) a, dbo.splitpra(@str2)                           
nbsp;  WHERE a.position=@i AND b.position=@i                       
   SET @i=@i+1                        
   Execute Query And PRocedure                       
  
 END  
 SELECT @totaltran 

Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+

Count Number Of Word In Sql Server

  Unknown       03:15       Function       No comments    

We Count HowMany Words Present in This String Through Function in Sql Server
Then Use This Code


CREATE FUNCTION fnCountOccurences     
               (@ShortString VARCHAR(100),     
                @LongString  VARCHAR(8000))     
RETURNS INT     
AS     
  BEGIN     
    DECLARE  @Text      VARCHAR(8000),     
             @Frequency INT     
         
    SET @Text = @LongString     
         
    SET @Text = REPLACE(@Text,@ShortString,'')     
         
    SET @Frequency = (len(rtrim(@LongString)) - len(rtrim(@Text)))     
                    / len(rtrim(@ShortString))     
         
    RETURN (@Frequency)     
  END

We Get OutPut:-

 SELECT[dbo].[fnCountOccurences](',','a,b,c,c,')
Execute
OutPut- 4
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+

Friday, 15 July 2016

Reset Identity Column in Sql Server

  Unknown       02:11       Queries       1 comment    

We Want To Reset Identity Column Then Use Code.If We Delete column By Id Like We delete 5 no id and
After Than we Insert New then We get 6 no Id .We Show Data 1 to 4 id then 6 because 5 no id We Deleted Then Use Code and Get 5 id In Example-
Example-
SELECT * FROM vibha1<Table Name> --Here Vibha1 is TableName
We get Values-











Delete data  from table
Ex.
DELETE FROM vibha1 WHERE id=6
One Value Delete then Insert Value
INSERT INTO vibha1(name) VALUES('vibha1')

Get Values-










Then We Use Code
Syntax: DBCC CHECKIDENT( <TableName>, RESEED, <ValuesThen Start>)
And Delete id 7 record
DELETE FROM vibha1 WHERE id=7
Then  Execute This
 DBCC CHECKIDENT( vibha1 , RESEED, 5)
Then Insert
INSERT INTO vibha1(name) VALUES('vibha1')
Now Get Result

Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+

Saturday, 9 July 2016

Asp.net- MultiView

  Unknown       00:26       Controls       1 comment    

MultiView and View controls allow you to divide the content of a page into different groups, displaying only one group at a time. Each View control manages one group of content and all the View controls are held together in a MultiView control.
The MultiView control is responsible for displaying one View control at a time. The View displayed is called the active view.

The syntax of MultiView control is:
<asp:MultView ID= "MultiView1" runat= "server">
</asp:MultiView>
 
The syntax of View control is:
 <asp:View ID= "View1" runat= "server">
</asp:View> 

However, the View control cannot exist on its own. It would render error
 if you try to use it stand-alone. It is always used with a Multiview 
control as:
<asp:MultView ID= "MultiView1" runat= "server">
   <asp:View ID= "View1" runat= "server"> </asp:View>
</asp:MultiView> 
 
Properties
ActiveViewIndex- A zero based index that denotes the active view. If no view is active, then the index is -1.

Example-
 Aspx Source Code-
<table border="0" cellpadding="2" cellspacing="3" width="100%">
<tr>
<td>
<asp:LinkButton ID="lnkTab1" runat="server" OnClick="lnkTab1_Click">Tab1</asp:LinkButton></td>
<td>
<asp:LinkButton ID="lnkTab2" runat="server" OnClick="lnkTab2_Click">Tab2</asp:LinkButton></td>
<td>
<asp:LinkButton ID="lnkTab3" runat="server" OnClick="lnkTab3_Click">Tab3</asp:LinkButton></td>
</tr>
<tr>
<td colspan="3">
<asp:MultiView ID="MultiView1" runat="server">
<table width="100%" cellpadding="2" cellspacing="5">
<tr>
<td>
<asp:View ID="View1" runat="server">
Content 1 goes here</asp:View>
</td>
<td>
<asp:View ID="View2" runat="server">
Content 2 goes here</asp:View>
</td>
<td>
<asp:View ID="View3" runat="server">
content 3 goes here</asp:View>
</td>
</tr>
</table>
</asp:MultiView></td>
</tr>
</table

C# Code
protected void Page_Load(object sender, EventArgs e)
{
  if (!IsPostBack)
   {
   SetDefaultView();
   }
}
private void SetDefaultView()
{
MultiView1.ActiveViewIndex = 0;
}
protected void lnkTab1_Click(object sender, EventArgs e)
{
MultiView1.ActiveViewIndex = 0;
}
protected void lnkTab2_Click(object sender, EventArgs e)
{
MultiView1.ActiveViewIndex = 1;
}
protected void lnkTab3_Click(object sender, EventArgs e)
{
MultiView1.ActiveViewIndex = 2;
}

OutPut-







Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+

Saturday, 25 June 2016

Table Structure Acces in Database

  Unknown       01:10       StoredProcedures       No comments    

Table Structure Get From  Database in Sql Server

If We Want To get Any  Table Structure from Database .
Show How Many Column Created and Datatype also Then Use This Code

Create Procedure in Sql Server

CREATE Procedure dbo.Gettable     
@tablename nvarchar(100)   
as     
    DECLARE    
           @object_name SYSNAME  ,      
          @object_id INT       
        , @SQL NVARCHAR(MAX)       
           
    SELECT       
          @object_name = '[' + OBJECT_SCHEMA_NAME(o.[object_id]) + '].[' + OBJECT_NAME([object_id]) + ']'       
        , @object_id = [object_id]       
    FROM (SELECT [object_id] = OBJECT_ID(@tablename, 'U')) o       
           
    SELECT @SQL = 'CREATE TABLE ' + @object_name + CHAR(13) + '(' + CHAR(13) + STUFF((       
        SELECT CHAR(13) + '    , [' + c.name + '] ' +        
            CASE WHEN c.is_computed = 1       
                THEN 'AS ' + OBJECT_DEFINITION(c.[object_id], c.column_id)       
                ELSE        
                    CASE WHEN c.system_type_id != c.user_type_id        
                        THEN '[' + SCHEMA_NAME(tp.[schema_id]) + '].[' + tp.name + ']'        
                        ELSE '[' + UPPER(tp.name) + ']'        
                    END  +        
                    CASE        
                        WHEN tp.name IN ('varchar', 'char', 'varbinary', 'binary')       
                            THEN '(' + CASE WHEN c.max_length = -1        
                                            THEN 'MAX'        
                                            ELSE CAST(c.max_length AS VARCHAR(5))        
                                        END + ')'       
                        WHEN tp.name IN ('nvarchar', 'nchar')       
                            THEN '(' + CASE WHEN c.max_length = -1        
                                            THEN 'MAX'        
                                            ELSE CAST(c.max_length / 2 AS VARCHAR(5))        
                                        END + ')'       
                        WHEN tp.name IN ('datetime2', 'time2', 'datetimeoffset')        
                            THEN '(' + CAST(c.scale AS VARCHAR(5)) + ')'       
                        WHEN tp.name = 'decimal'       
                            THEN '(' + CAST(c.[precision] AS VARCHAR(5)) + ',' + CAST(c.scale AS VARCHAR(5)) + ')'       
                        ELSE ''       
                    END +       
                    CASE WHEN c.collation_name IS NOT NULL AND c.system_type_id = c.user_type_id        
                        THEN ' COLLATE ' + c.collation_name       
                        ELSE ''       
                    END +       
                    CASE WHEN c.is_nullable = 1        
                        THEN ' NULL'       
                        ELSE ' NOT NULL'       
                    END +       
                    CASE WHEN c.default_object_id != 0        
                        THEN ' CONSTRAINT [' + OBJECT_NAME(c.default_object_id) + ']' +        
                             ' DEFAULT ' + OBJECT_DEFINITION(c.default_object_id)       
                        ELSE ''       
                    END +        
                    CASE WHEN cc.[object_id] IS NOT NULL        
                        THEN ' CONSTRAINT [' + cc.name + '] CHECK ' + cc.[definition]       
                        ELSE ''       
                    END +       
                    CASE WHEN c.is_identity = 1        
                        THEN ' IDENTITY(' + CAST(IDENTITYPROPERTY(c.[object_id], 'SeedValue') AS VARCHAR(5)) + ',' +        
                                        CAST(IDENTITYPROPERTY(c.[object_id], 'IncrementValue') AS VARCHAR(5)) + ')'        
                        ELSE ''        
                    END        
            END       
        FROM sys.columns c WITH(NOLOCK)       
        JOIN sys.types tp WITH(NOLOCK) ON c.user_type_id = tp.user_type_id       
        LEFT JOIN sys.check_constraints cc WITH(NOLOCK)        
             ON c.[object_id] = cc.parent_object_id        
            AND cc.parent_column_id = c.column_id       
        WHERE c.[object_id] = @object_id       
        ORDER BY c.column_id       
     FOR XML PATH(''), TYPE).value('.', 'NVARCHAR(MAX)'), 1, 7, '      ') +        
        ISNULL((SELECT '       
        , CONSTRAINT [' + i.name + '] PRIMARY KEY ' +        
        CASE WHEN i.index_id = 1        
            THEN 'CLUSTERED'        
            ELSE 'NONCLUSTERED'        
        END +' (' + (       
        SELECT STUFF(CAST((       
            SELECT ', [' + COL_NAME(ic.[object_id], ic.column_id) + ']' +       
                    CASE WHEN ic.is_descending_key = 1       
                        THEN ' DESC'       
                        ELSE ''       
                    END       
            FROM sys.index_columns ic WITH(NOLOCK)       
            WHERE i.[object_id] = ic.[object_id]       
                AND i.index_id = ic.index_id       
            FOR XML PATH(N''), TYPE) AS NVARCHAR(MAX)), 1, 2, '')) + ')'       
        FROM sys.indexes i WITH(NOLOCK)       
        WHERE i.[object_id] = @object_id       
            AND i.is_primary_key = 1), '') + CHAR(13) + ');'       
           
    PRINT @SQL


Use This Code We Show table Structure like

SELECT * FROM tbl_Acc_Type
After Execution We get Table
 
ID    AccType
1    Payment
2    Receipt

We Use table Structure Then Use this Procedure To Directaly Show Structure
Syntax-  GetTable  TableName
Ex.-   GetTable tbl_Acc_Type

After Execution We get Table Structure

CREATE TABLE [dbo].[tbl_Acc_Type]
(
      [ID] [INT] NOT NULL IDENTITY(1,1)
    , [AccType] [NVARCHAR](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL     
        , CONSTRAINT [PK_tbl_Acc_Type] PRIMARY KEY CLUSTERED ([ID])
);


We Will Create This Table in Other Database and use Structure Also


 
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
Newer Posts Older Posts Home

Popular Posts

  • Auto Increment Id in Sql Server
    SQL server identity column values use in table Steps- Firstly Open-> Sql Server Create Table -> First Field Like ID Usually Autoi...
  • MVC Framework Architecture
    MVC Flow- MVC application takes place when certain request comes from the client. The diagram below shows the flow: Flow Steps ...
  • Create First MVC Application
    How to create MVC First simple application It is very easy to make application in mvc follow some steps and create first application ST...
  • Reset Identity Column in Sql Server
    We Want To Reset Identity Column Then Use Code.If We Delete column By Id Like We delete 5 no id and After Than we Insert New then We get 6...
  • Unicque Row Num and Same Rank in Sql server
     Use Of  Row_Number() ,Rank() function , Dense_Rank() Row_Number() This function will assign a unique id to each row returned from t...
  • Create Table
    Create Table In Sql Server Syntax- CREATE TABLE TableName ( ColumnName1  INT PRIMARY KEY IDENTITY, ColumnName2, ColumnName3 ) Ex.  C...
  • Email Validation In JavaScript
    We use Validation for Email  in Javascript like in above example <!DOCTYPE html> <html> <head> <script> fu...
  • Numeric Value Validation Through JavaScript
    Validate Only Numeric Value Enter In TextBox Using JavaScript function Firstly Write Java Script Function in <head tag> in Asp.Net ...
  • Asp.net- MultiView
    MultiView and View controls allow you to divide the content of a page into different groups, displaying only one group at a time. Each Vie...
  • The Evolution of MVC
    Microsoft had introduced ASP.NET MVC in .Net 3.5,since then lots of new features have been added.The following table list brief history of ...

Blog Archive

  • ▼  2016 ( 36 )
    • ►  February ( 1 )
    • ►  March ( 5 )
    • ►  April ( 1 )
    • ►  June ( 10 )
      • Table Structure Acces in Database
    • ►  July ( 6 )
      • Asp.net- MultiView
      • Reset Identity Column in Sql Server
      • Count Number Of Word In Sql Server
      • Values Enter With SplitFunction in Sql Server
      • Split Function in Sql Serever
      • Numeric Value Validation Through JavaScript
    • ►  November ( 8 )
      • Get Random Rows in SqlServer
      • MVC OverView
      • Main Advantage Of MVC
      • MVC vs ASP.NET
      • The Evolution of MVC
      • MVC Framework Architecture
      • Auto Increment Id in Sql Server
      • Install Visual Stdio Step by Step Process
    • ▼  December ( 5 )
      • Collapse Function Use in Bootstrap.
      • Email Validation In JavaScript
      • Javascript Regular Expression Email Validate
      • Open First Application in MVC
      • Create First MVC Application
  • ►  2017 ( 1 )
    • ►  January ( 1 )
Powered by Blogger.

Categories

  • Ajax
  • AllFunction
  • Controls
  • CreateApplication
  • css
  • Function
  • javascript
  • Js
  • over view
  • OverView
  • Queries
  • StoredProcedures

Text Widget

Sample Text

Pages

  • Home

Copyright © DotNet Solution | Powered by Blogger
Design by Vibha Acharya