[Solved] DropdownList value is getting null in ASP.NET MVC

As you said in the comment that: after submitting the form companyId = null This is actually becuase your drop down select input field name is CompanyName instead of CompanyId So name it CompanyId as follows: <div class=”form-group”> <strong class=”strong”>Company Name</strong> <div class=”col-md-10″> @Html.DropDownList(“CompanyId”, (IEnumerable<SelectListItem>)ViewBag.CompanyName, “Select Company”, new { @class = “form-control” }) @Html.ValidationMessageFor(model => … Read more

[Solved] convert numeric + alphabetical string [closed]

Maybe you want to extract digits only to create a long? You could use Char.IsDigit and LINQ: Char[] digitsOnly = “3e317188a00577”.Where(Char.IsDigit).ToArray(); if(digitsOnly.Length > 0) { long result; if (long.TryParse(new string(digitsOnly), out result)) { Console.Write(“Successfully parsed to: ” + result); } } Result: Successfully parsed to: 331718800577 If you instead want to parse it from hexadecimal … Read more

[Solved] how to pass viewbag data from view to another component template that I call in this view

If I understood correctly you can do this by using the same controller for your second view, like writing ng-controller=”SameController” or creating an angular service or factory and sharing your data between two different controllers that each one serves a specific template/view. 6 solved how to pass viewbag data from view to another component template … Read more

[Solved] Check string format consist of specific words then number then specific words in c# [closed]

It’s really easy to make a regular expression to get matches: string[] input = new string[6] { “[email protected]”, // match “[email protected]”, // match “[email protected]”, // match “[email protected]”, // not a match “[email protected]”, // not a match “[email protected]” // not a match }; string pattern = @”Auto_gen_\d{4}@mail.com”; //\d{4} means 4 digits foreach (string s in input) … Read more

[Solved] Upload file using file path as string in c#

File-handling is all fairly new to me but, this is how I’ve done it in a recent MVC project. ImageController: this is how I’m saving the file public ActionResult Create(FormCollection collection) { if (ModelState.IsValid) { HttpPostedFileBase file = Request.Files[“userUploadedFile”]; var userName = User.Identity.Name; var selectAlbum = Request.Form[“lstAlbums”]; Image img = new Image(); img.FileName = file.FileName; … Read more

[Solved] Finding location using google API in mvc 5

I have worked with freegeoip and to get the geo location from this is as below. URL:- http://freegeoip.net/xml/{ip} In this you can provide your IP and can see result in browser. Implementation in code. string apiUrl = http://freegeoip.net/xml/{ip} HttpClient HttpClient = new HttpClient(); var response = HttpClient.GetAsync(apiUrl).Result; if (response != null && response.ReasonPhrase != “Unauthorized”) … Read more

[Solved] How to implement currency conversion

Please change you code with below code [WebMethod] public decimal ConvertGOOG(decimal amount, string fromCurrency, string toCurrency) { WebClient web = new WebClient(); string apiURL = String.Format(“http://finance.google.com/finance/converter?a={0}&from={1}&to={2}”, amount, fromCurrency.ToUpper(), toCurrency.ToUpper()); string response = web.DownloadString(apiURL); var split = response.Split((new string[] { “<span class=bld>” }), StringSplitOptions.None); var value = split[1].Split(‘ ‘)[0]; decimal rate = decimal.Parse(value, CultureInfo.InvariantCulture); return rate; … Read more

[Solved] Jquery tabs with mvc partial views [closed]

This doesn’t really have anything to do with actions, it’s just a matter of including the desired content in your view. It could be as simple as this: <div id=”tabs”> <ul> <li><a href=”#tabs-1″>first tab</a></li> <li><a href=”#tabs-2″>second tab</a></li> <li><a href=”#tabs-3″>third tab</a></li> </ul> <div id=”tabs-1″> first tab content </div> <div id=”tabs-2″> second tab content </div> <div id=”tabs-3″> … Read more

[Solved] How create ajax request manually? [closed]

If all you want is a basic request then you can do it easily without any libraries with the functions find here http://www.quirksmode.org/js/xmlhttp.html function sendRequest(url,callback,postData) { var req = createXMLHTTPObject(); if (!req) return; var method = (postData) ? “POST” : “GET”; req.open(method,url,true); req.setRequestHeader(‘User-Agent’,’XMLHTTP/1.0′); if (postData) req.setRequestHeader(‘Content-type’,’application/x-www-form-urlencoded’); req.onreadystatechange = function () { if (req.readyState != 4) … Read more

[Solved] which architecture is good for implementing in this project? [closed]

Create a new MVC project and then install CodePlanner from nuget. Install-Package CodePlanner This will give you the architecture you are looking for. Then follow the instructions in the readme.txt… It will give you the chance to use DDD and will generate all code except business logic (of course). You can see a demo of … Read more