Hello Guys,
Insert update delete using Entity framework. Here is very nice Explanation.
<httpRuntime requestValidationMode="2.0"/>
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Runtime.InteropServices; using System.IO; using Microsoft.Win32; namespace CustomWallpaper { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private static readonly UInt32 SPI_SETDESKWALLPAPER = 0x14; private static readonly UInt32 SPIF_UPDATEINIFILE = 0x01; private static readonly UInt32 SPIF_SENDWININICHANGE = 0x02; [DllImport("user32.dll", CharSet = CharSet.Auto)] private static extern Int32 SystemParametersInfo( UInt32 action, UInt32 uParam, String vParam, UInt32 winIni); private void Form1_Load(object sender, EventArgs e) { string strPath = "D:\\Projects\\Wallpaper\\Wallpaper.jpg"; if (File.Exists(strPath)) { SetWallpaper(strPath); } else { strPath = "D:\\Projects\\Wallpaper\\Wallpaper.jpeg"; if (File.Exists(strPath)) { SetWallpaper(strPath); } else { strPath = "D:\\Projects\\Wallpaper\\Wallpaper.png"; if (File.Exists(strPath)) { SetWallpaper(strPath); } else { MessageBox.Show("Wallpaper.jpg Or Wallpaper.jpeg OR Wallpaper.png is not found on this path D:\\Projects\\Wallpaper\\"); this.Close(); } } } } private void SetWallpaper(string path) { SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, path,SPIF_UPDATEINIFILE | SPIF_SENDWININICHANGE); RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Control Panel\Desktop", true); key.SetValue(@"WallpaperStyle", 2.ToString()); key.SetValue(@"TileWallpaper", 0.ToString()); this.Close(); } } }
Here below is Jquery functions required to bind the dropdown list. Let me explain how these functions are working.
<%-- Here is dropdowns --%> @{ ViewBag.Title = "DropDown"; }DropDown
Country : | @Html.DropDownList("Country", (IEnumerable |
State : | |
City : |
'Here is controller code namespace MvcApplication1.Controllers { public class NikController : Controller { public ActionResult DropDown() { ListHere it is how it look likes.items = new List (); items.Add(new SelectListItem { Text = "---Select Country---", Value = "0", Selected = true }); items.Add(new SelectListItem { Text = "India", Value = "1",Selected= true }); items.Add(new SelectListItem { Text = "USA", Value = "2" }); items.Add(new SelectListItem { Text = "Russia", Value = "3"}); items.Add(new SelectListItem { Text = "South Africa", Value = "4" }); ViewBag.Country = items; return View(); } public ActionResult GetState(int Countryid) { List States = new List (); if (Countryid==1) { States.Add(new SelectListItem { Text = "Gujarat", Value = "1", Selected = true }); States.Add(new SelectListItem { Text = "Maharashtra", Value = "2"}); States.Add(new SelectListItem { Text = "Rajsthan", Value = "3"}); States.Add(new SelectListItem { Text = "Punjab", Value = "4"}); States.Add(new SelectListItem { Text = "MP", Value = "5" }); States.Add(new SelectListItem { Text = "Keral", Value = "6" }); States.Add(new SelectListItem { Text = "Karnatak", Value = "7"}); States.Add(new SelectListItem { Text = "Jammu", Value = "8"}); States.Add(new SelectListItem { Text = "Assam", Value = "9"}); States.Add(new SelectListItem { Text = "AP", Value = "10"}); } else if(Countryid ==2) { States.Add(new SelectListItem { Text = "Alabama", Value = "11", Selected = true }); States.Add(new SelectListItem { Text = "Alaska", Value = "12"}); States.Add(new SelectListItem { Text = "Arizona", Value = "13"}); States.Add(new SelectListItem { Text = "Arkansas", Value = "14"}); States.Add(new SelectListItem { Text = "California", Value = "15"}); States.Add(new SelectListItem { Text = "Colorado", Value = "16"}); States.Add(new SelectListItem { Text = "Connecticut", Value = "17"}); States.Add(new SelectListItem { Text = "Delaware", Value = "18"}); States.Add(new SelectListItem { Text = "Florida", Value = "19" }); States.Add(new SelectListItem { Text = "Georgia", Value = "20"}); } return Json(States); } public ActionResult GetCity(int Stateid) { List City = new List (); if (Stateid == 1) { City.Add(new SelectListItem { Text = "Ahmedabad", Value = "1", Selected = true }); City.Add(new SelectListItem { Text = "Surat", Value = "2" }); City.Add(new SelectListItem { Text = "Baroda", Value = "3" }); City.Add(new SelectListItem { Text = "Rajkot", Value = "4" }); City.Add(new SelectListItem { Text = "Jamnagar", Value = "5" }); City.Add(new SelectListItem { Text = "Junagadh", Value = "6" }); City.Add(new SelectListItem { Text = "Jetpur", Value = "7" }); City.Add(new SelectListItem { Text = "Bharuch", Value = "8" }); City.Add(new SelectListItem { Text = "Limabi", Value = "9" }); City.Add(new SelectListItem { Text = "Vapi", Value = "10" }); } return Json(City); } } }