Posts

Handling multiple submit buttons on the same form

Method 1 - Submit the form for each button @using ( Html . BeginForm ( "Department" , "Edit" , FormMethod . Post , new { id = "submitForm" })) {                        <div class="form-elements">             @Html.Label("Department Code:*", new { id = "lblDepartmentCode" })             @Html.TextBoxFor(model => model.DepartmentCode, new { id = "txtDepartmentCode" })             @Html.ValidationMessageFor(model => model.DepartmentCode)       </div>       <div class="form-elements">            @Html.Label("Department Name:*", new { id = "lblDepartmentName" })            @Html.TextBoxFor(model => model.DepartmentName, new { id = "txtDepartmentName" })           ...

ViewData vs ViewBag vs TempData vs Session

Image
In MVC there are three ways - ViewData, ViewBag and TempData to pass data from controller to view . We can also use Session to persist data during a user session. ViewData ViewData is a dictionary object that is derived from ViewDataDictionary class.      public ViewDataDictionary ViewData { get; set; } ViewData is a property of ControllerBase class. ViewData is used to pass data from controller to corresponding view. It’s life lies only during the current request. If redirection occurs then it’s value becomes null. It’s required typecasting for getting data and check for null values to avoid error. ViewBag ViewBag is a dynamic property that takes advantage of the new dynamic features in C# 4.0. Basically it is a wrapper around the ViewData and also used to pass data from controller to corresponding view.      public Object ViewBag { get; } ViewBag is a property of ControllerBase class. It’s life also lies only during the curren...

Augmented Reality

Steps To Follow 1.Go to the site https://developer.vuforia.com - Register and then login 2. In Target Manager Create Database, Add the target to the dataset. (Add width of the image. Image size will be width*Height)The no. of stars indicate the level to which the target can be augmented. 0 stars indicate the target cannot be augmented. 3. Select download to download the dataset to the unity editor 4. Go to unity, right click Assets->Import Package-> Custom Packages select all and click import 5. Select AR Camera and select the dataset and the target image. 6.Check the below checkboxes. · load dataset name · activate To Augment an object: 1. Go to Assets->Qualcom Augmented Reality->Prefab->Image Target 2. Drag and drop Image target to Hierarchy 3. From the Image target Behaviour select Dataset and Image Target 4. Create a gameobject(cube) as a child of image target, scale it to the required size. To Augment a Video: 1. Add vid...

Unity 3D

What is Unity3D? Unity3D is a powerful cross-platform 3D engine and a user friendly development environment. Easy enough for the beginner and powerful enough for the expert; Unity should interest anybody who wants to easily create 3D games and applications for mobile, desktop, the web, and consoles. Creating a Prefab A Prefab is a stored collection containing one or more complete GameObjects with components attached and properties set. Prefabs are asset types, so they do not appear in the scene in their own right. However, they can be used to create instances of the stored objects in the scene. Each instance is a copy of the original prefab. For example, you might use a prefab to store a tree object and then create many instances of the tree in a forest scene. By default, changes made to the prefab are automatically applied to all the instances, and so using prefabs can be a good way to maintain consistency among a set of objects. However, you can also break the link between the i...

Filters Using Dataset and Dataview

Using Dataset filtering the data and merging it to the same Dataset ds = Select * from Query; QryStr = "ID =" + 3; DataSet dsview = new DataSet(); dsview = ds; DataRow[] dr = dsview.Tables[1].Select(QryStr); if (dr.Length > 0) {      DataTable dt = dsview.Tables[1].Select(QryStr).CopyToDataTable();      ds.Tables[1].Clear();     ds.Tables[1].Merge(dt); } Using Dataview filtering the data  ds = Select * from Query; DataView dvstatus = new DataView(ds.Tables[0]); string QryStr = string.Empty; QryStr = "ID = 2 " + " Or ID = 3" + " Or ID = 7"; dvstatus.RowFilter = QryStr;  if (dvstatus.Count > 0) {    ddlStatus.DataSource = dvstatus;    ddlStatus.DataBind; }

Array, Arraylist, Hashtable, DataDicitonary in C#

Difference between Hash table and Data Dictionary in C#     HashTable & Dictionary,Dictionary is generic whereas Hastable is not Generic. · We can add any type of object to HashTable ,but while reteriving we need to Cast it to the required Type.So it is not type safe.But to dictionary,while declaring itself we can specify the type of Key & Value ,so no need to cast while retreiving. HashTable Program: Hashtable ht = new Hashtable(); ht.Add(1,"One"); ht.Add(2,"Two"); ht.Add(3,"Three"); foreach (DictionaryEntry de in ht) { int Key = (int)de.Key; //Casting string value = de.Value.ToString(); //Casting Console.WriteLine( Key + " " + value); } Dictionary Example class DictionaryProgram { static void Main(string[] args) { Dictionary<int,string> dt = new Dictionary<int,string>(); dt.Add(1,"One"); dt.Add (2,"Two"); dt.Add (3,"Three"); foreach (KeyValuePair...

Interview Questions

Difference between GET and POST. Which one is more secure? GET and POST methods are used for the data transfer between the web pages. GET mainly used for small data which is not secure because in case of GET method, the data which we are passing will be visible in the url so we can't keep the secure data which will be visible in the url. There is also limited data which can be passed in case of GET method (max 255 character). POST is used for transferring the huge data between the pages where we can keep the secure data and can transfer it. In case of using the POST method, the data which is transferring between the pages will not be visible so it is more secure than the GET method. Also there is no limit for POST method to post the data to the next page. POST is more secure What are Razor engines? How is it diff from ASP Engines? A. RAZOR engine is the new concept in the MVC 3 which is mainly used to create the views in the MVC applications. It created the cshtml pages for...