Posts

Showing posts from June, 2023

Q ) How to turn of validation when Binding Data (Turn Of validation when bind data )

  Q )   How to off validation when Find data in Asp.Net C# ?   Logic  :- Put this( CausesValidation ="False" ) attribute in the button with which you are binding the data     < asp : TextBox   ID ="txtlname"   runat ="server"   class ="input--style-5"   placeholder ="Last Name"   ></ asp : TextBox > < asp : RequiredFieldValidator   ID ="RequiredFieldValidator1"   runat ="server"   ErrorMessage ="Last Name Is Required"   ForeColor ="Red"   Font-Bold ="true"   ControlToValidate ="txtlname"></ asp : RequiredFieldValidator >                                        < asp : Button   CausesValidation ="False"   ID ="Button3"   runat ="server"   Text ="Find"   Height ="50px"   Wi...

Z 10 ) PARTIAL VIEWS IN ASP.NET MVC

Image
     PARTIAL VIEWS IN ASP.NET MVC ·  Partial view represents a sub-view of a main view. ·  Partial view allows you to reuse common markups across the different views of the application. ·  We can use partial views in different views. ·  Partial views cannot be used separately, we have to attach partial in some other view. ·  Partial view extension is .cshtml like a view. ·  When we have to use some html markup on some pages not all pages then we can use partial view. To create a partial view in Visual Studio .NET, you need to perform the following steps: 1.  Right-click the Views/Shared folder in the Solution Explorer window and select Add View. The AddView dialog box is displayed. 2.  In the AddView dialog box, specify a name for the partial view in the View Name text field. 3.  Select the Create as a partial view check box. There are 2 types of partial views. 1.  Static a.  Views whose layout not changed i.e header,...

Z 9 ) STRONGLY TYPED VIEW IN ASP.NET MVC

Image
  STRONGLY TYPED VIEW IN ASP.NET MVC Ø  Strongly typed view or strongly typed object is used to pass data from controller to a view. Ø  The view which binds with any model is called as strongly typed view. Ø  You can bind any class as a model to view. Ø  You can access model properties on that view. Ø  You can use data associated with model to render controls. Ø  The view that is designed by targeting specific model class object then that view is called "Strongly Typed View". In strongly typed view, view is bind with corresponding model class object or list of objects. There are several ways available to pass data from a controller to a view in an MVC application. 1.  ViewBag or ViewData 2.  Dynamic Type 3.  Strongly typed view Benefits of using strongly typed views. ·  Compile time error checking ·  Intellisense

Z 8 ) MVC HTMLHELPER METHOD AND ACTIONLINK (how to use css ,atrributes,style in css)

Image
  HTML HELPER METHODS IN ASP.NET MVC 5 In ASP.NET MVC Framework, helper methods: Ø  Are extension methods to the Html Helper class, can be called only from views. Ø  An HTML helper is a method that is used to render html content in a view. Ø  Simplifies the process of creating a view. Ø  Allows generating HTML markup that you can reuse across the Web application. Some of the commonly used helper methods while developing an MVC application are as follows: Ø  Html.ActionLink() Ø  Html.BeginForm() and Html.EndForm() Ø  Html.Label() Ø  Html.TextBox() Ø  Html.TextArea() Ø  Html.Password() Ø  Html.CheckBox()

Z 7) ViewData__ViewBag__TempData__Session

Image
Theory :- PASSING DATA FROM A CONTROLLER TO A VIEW IN MVC In an ASP.NET MVC application, a controller typically performs the business logic of the application and needs to return the result to the user through a view. You can use the following objects to pass data between controller and view: Ø  ViewData Ø  ViewBag Ø  TempData ViewData ·  Passes data from a controller to a view. ·  Is a dictionary of objects that is derived from the ViewDataDictionary  class. ·  Some of the characteristics of ViewData are as follows: ·  The life of a ViewData object exists only during the current request. ·  The value of ViewData becomes null if the request is redirected. ·  ViewData requires typecasting when you use complex data type to avoid error. The general syntax of ViewData is as follows: ViewData[“<Key>”] = <Value>; where, Ø  Key : Is a String value to identify the object present in ViewData. Ø  Value : Is the object present...