Search Results

Search found 386 results on 16 pages for 'viewdata'.

Page 10/16 | < Previous Page | 6 7 8 9 10 11 12 13 14 15 16  | Next Page >

  • Best way of implementing DropDownList in ASP.NET MVC 2?

    - by Kelsey
    I am trying to understand the best way of implementing a DropDownList in ASP.NET MVC 2 using the DropDownListFor helper. This is a multi-part question. First, what is the best way to pass the list data to the view? Pass the list in your model with a SelectList property that contains the data Pass the list in via ViewData How do I get a blank value in the DropDownList? Should I build it into the SelectList when I am creating it or is there some other means to tell the helper to auto create an empty value? Lastly, if for some reason there is a server side error and I need to redisplay the screen with the DropDownList, do I need to fetch the list values again to pass into the view model? This data is not maintained between posts (at least not when I pass it via my view model) so I was going to just fetch it again (it's cached). Am I going about this correctly?

    Read the article

  • Can't disable jQuery cache

    - by robert_d
    Update I figured out that it must be caching problem but I can't turn cache off. Here is my changed script: <script src="../../Scripts/jquery-1.4.1.js" type="text/javascript"></script> <script type="text/javascript"> jQuery.ajaxSetup({ // Disable caching of AJAX responses cache: false }); jQuery("#button1").click(function (e) { window.setInterval(refreshResult, 3000); }); function refreshResult() { jQuery("#divResult").load("/Home/Refresh"); } </script> It updates part of a web page every 3 sec. It works only once after clearing web browser cache, after that it doesn't work - requests are made to /Home/Refresh without interval of 3 seconds and nothing is displayed on the web page; subsequent requests send cookie ASP.NET_SessionId=wrkx1avgvzwozcn1frsrb2yh. I am using ASP.NET MVC 2 and c#. I have a problem with jQuery, here is how my web app works Search.aspx web page which contains a form and jQuery script posts data to Search() action in Home controller after user clicks button1 button. Search.aspx: <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<GLSChecker.Models.WebGLSQuery>" %> <asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server"> Title </asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> <h2>Search</h2> <% Html.EnableClientValidation(); %> <% using (Html.BeginForm()) {%> <fieldset> <div class="editor-label"> <%: Html.LabelFor(model => model.Url) %> </div> <div class="editor-field"> <%: Html.TextBoxFor(model => model.Url, new { size = "50" } ) %> <%: Html.ValidationMessageFor(model => model.Url) %> </div> <div class="editor-label"> <%: Html.LabelFor(model => model.Location) %> </div> <div class="editor-field"> <%: Html.TextBoxFor(model => model.Location, new { size = "50" } ) %> <%: Html.ValidationMessageFor(model => model.Location) %> </div> <div class="editor-label"> <%: Html.LabelFor(model => model.KeywordLines) %> </div> <div class="editor-field"> <%: Html.TextAreaFor(model => model.KeywordLines, 10, 60, null)%> <%: Html.ValidationMessageFor(model => model.KeywordLines)%> </div> <p> <input id ="button1" type="submit" value="Search" /> </p> </fieldset> <% } %> <script src="../../Scripts/jquery-1.4.1.js" type="text/javascript"></script> <script type="text/javascript"> jQuery("#button1").click(function (e) { window.setInterval(refreshResult, 5000); }); function refreshResult() { jQuery("#divResult").load("/Home/Refresh"); } </script> <div id="divResult"> </div> </asp:Content> [HttpPost] public ActionResult Search(WebGLSQuery queryToCreate) { if (!ModelState.IsValid) return View("Search"); queryToCreate.Remote_Address = HttpContext.Request.ServerVariables["REMOTE_ADDR"]; Session["Result"] = null; SearchKeywordLines(queryToCreate); Thread.Sleep(15000); return View("Search"); }//Search() After button1 button is clicked the above script from Search.aspx web page runs. Search() action in controller runs for longer period of time. I simulate this in testing by putting Thread.Sleep(15000); in Search()action. 5 sec. after Submit button was pressed, the above jQuery script calls Refresh() action in Home controller. public ActionResult Refresh() { ViewData["Result"] = DateTime.Now; return PartialView(); } Refresh() renders this partial <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" % <%= ViewData["Result"] % The problem is that in Internet Explorer 8 there is only one request to /Home/Refresh; in Firefox 3.6.3 all requests to /Home/Refresh are made but nothing is displayed on the web page. Another problem with Firefox is that requests to /Home/Refresh are made every second not every 5 seconds. I noticed that after I clear Firefox cache the script works well first time button1 is pressed, but after that it doesn't work. I would be grateful for helpful suggestions.

    Read the article

  • How to return model state from child action handler in ASP.NET MVC

    - by Joe Future
    In my blog engine, I have one controller action that displays blog content, and in that view, I call Html.RenderAction(...) to render the "CreateComment" form. When a user posts a comment, the post is handled by the comment controller (not the blog controller). If the comment data is valid, I simply return a Redirect back to the blog page's URL. If the comment data is invalid (e.g. comment body is empty), I want to return the ViewData with the error information back to the blog controller and through the blog view to the CreateComment action/view so I can display which fields are bad. I have this working fine via AJAX when Javascript is enabled, but now I'm working on the case where Javascript might be disabled. If I return a RedirecToAction or Redirect from the comment controller, the model state information is lost. Any ideas?

    Read the article

  • ASP.Net MVC view unable to see HtmlHelper extension method

    - by larryq
    Hi everyone, We're going through an ASP.Net MVC book and are having trouble with using an extenstion method within our view. The Extension method looks like this: using System; using System.Runtime.CompilerServices; using System.Web.Mvc; namespace MvcBookApplication { public static class HtmlHelperExtensions { public static string JQueryGenerator(this HtmlHelper htmlHelper, string formName, object model); } } We use the extension method in our view like this: <%=Html.JQueryGenerator("createmessage", ViewData.Model)%> The problem is, that line of code says JQueryGenerator isn't a recognized method of HtmlHelper. I believe we've got the correct references set in the web project, but are there other things we can check? There's no using statement for views, is there?

    Read the article

  • Get the selected drop down list value from a FormCollection in MVC

    - by James Santiago
    I have a form posting to an action with MVC. I want to pull the selected drop down list item from the FormCollection in the action. How do I do it? My Html form: <% using (Html.BeginForm()) {%> <select name="Content List"> <% foreach (String name in (ViewData["names"] as IQueryable<String>)) { %> <option value="<%= name %>"><%= name%></option> <% } %> </select> <p><input type="submit" value="Save" /></p> <% } %> My Action: [HttpPost] public ActionResult Index(FormCollection collection) { //how do I get the selected drop down list value? String name = collection.AllKeys.Single(); return RedirectToAction("Details", name); }

    Read the article

  • Html Attribute for Html.Dropdown

    - by kapil
    I am using a dropdown list as follows. <%=Html.DropDownList("ddl", ViewData["Available"] as SelectList, new { CssClass = "input-config", onchange = "this.form.submit();" })%> On its selection change I am invoking post action. After the post the same page is shown on which this drop down is present. I want to know about the HTML attribute for the drop down which will let me preserve the list selection change. But as of now the list shows its first element after the post. e.g. The dropdoen contains elements like 1,2,3,etc. By default 1 is selected. If I select 2, the post is invoked and the same page is shown again but my selection 2 goes and 1 is selected again. How can preserve the selection? Thanks, Kapil

    Read the article

  • Rendering a derived partial view with Html.RenderPartial

    - by FreshCode
    Calling Html.RenderPartial("~/Views/Payments/MyControl.ascx"); from a view works if Method.ascx is a control that directly inherits System.Web.Mvc.ViewUserControl. However, if the control inherits a new class that derives from System.Web.Mvc.ViewUserControl, the call to Html.RenderPartial("~/Views/Payments/MyDerivedControl.ascx"); fails, reporting that no such view exists. Example derived ViewUserControl: class MyDerivedControl : System.Web.Mvc.ViewUserControl { public Method() { ViewData["SomeData"] = "test"; } } Is there a workaround, or is there another way I should be doing this? Perhaps an HTML helper?

    Read the article

  • MVC in a Google App Engine Java world

    - by thatismatt
    I'm coming to Java from C# & ASP.NET MVC, I'd love to find an equivalent in the Java world that I could use on the Google App Engine. I've already started to have a play with FreeMarker and even made the first steps towards writing a very simple framework. Ideally I wouldn't have to do all the hard work though, someone must have done this already! So my question is - what frameworks are there out there that would be familiar for me coming from ASP.NET MVC and I could use them on Google App Engine for Java. The key things I'd want are: Simple Routing - /products/view/1 gets mapped to the view action of the products controller with the productid of 1 Template Engine - some way of easily passing 'ViewData' to the view, and from the view easily accessing it, ideally I'd love to avoid anything that is too XMLy (thus why I like FreeMarker).

    Read the article

  • Localize DisplayNameAttributes in ActionFilter?

    - by boris callens
    Is it possible to access the DisplayNameAttributes that are used on my ViewData.Model so I can Localize them before sending them to the view? Something like this: Public Void OnActionExecuted(ActionExecutedContext: filterContext) { foreach (DisplayNameAttribute attr in filterContext...) { attr.TheValue = AppMessages.GetLocazation(attr.TheValue); } } What I'm missing is how to access the attributes. Is this possible at all? P.S: We're using vb.net at my job and it's infiltrating my brain. So apologies if my C# is a tad off.

    Read the article

  • ASP MVC Set RadioButton From Database

    - by Jacob Huggart
    Hello All, I have what should be an easy question for you today. I have two radio buttons in my view: Sex: <%=Html.RadioButton("Sex", "Male", true)% Male <%=Html.RadioButton("Sex", "Female", true)% Female I need to select one based on the value returned from my database. The way I am trying to do it now is: ViewData["Sex"] = data.Sex; //Set radio button But that is not working. I have tried every possible combination of isChecked properties. I know that data.Sex is returning either "Male" or "Female". What do I need to do to check the appropriate radio button?

    Read the article

  • ASP.NET MVC unit test controller with HttpContext

    - by user299592
    I am trying to write a unit test for my one controller to verify if a view was returned properly, but this controller has a basecontroller that accesses the HttpContext.Current.Session. Everytime I create a new instance of my controller is calls the basecontroller constructor and the test fails with a null pointer exception on the HttpContext.Current.Session. Here is the code: public class BaseController : Controller { protected BaseController() { ViewData["UserID"] = HttpContext.Current.Session["UserID"]; } } public class IndexController : BaseController { public ActionResult Index() { return View("Index.aspx"); } } [TestMethod] public void Retrieve_IndexTest() { // Arrange const string expectedViewName = "Index"; IndexController controller = new IndexController(); // Act var result = controller.Index() as ViewResult; // Assert Assert.IsNotNull(result, "Should have returned a ViewResult"); Assert.AreEqual(expectedViewName, result.ViewName, "View name should have been {0}", expectedViewName); } Any ideas on how to mock the Session that is accessed in the base controller so the test in the descendant controller will run?

    Read the article

  • Problem with jQuery and ASP.Net MVC

    - by robert_d
    I have a problem with jQuery, here is how my web app works Search web page which contains a form and jQuery script posts data to Search() action in Home controller after user clicks button1 button. Search.aspx: <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<GLSChecker.Models.WebGLSQuery>" %> <asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server"> Title </asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> <h2>Search</h2> <% Html.EnableClientValidation(); %> <% using (Html.BeginForm()) {%> <fieldset> <div class="editor-label"> <%: Html.LabelFor(model => model.Url) %> </div> <div class="editor-field"> <%: Html.TextBoxFor(model => model.Url, new { size = "50" } ) %> <%: Html.ValidationMessageFor(model => model.Url) %> </div> <div class="editor-label"> <%: Html.LabelFor(model => model.Location) %> </div> <div class="editor-field"> <%: Html.TextBoxFor(model => model.Location, new { size = "50" } ) %> <%: Html.ValidationMessageFor(model => model.Location) %> </div> <div class="editor-label"> <%: Html.LabelFor(model => model.KeywordLines) %> </div> <div class="editor-field"> <%: Html.TextAreaFor(model => model.KeywordLines, 10, 60, null)%> <%: Html.ValidationMessageFor(model => model.KeywordLines)%> </div> <p> <input id ="button1" type="submit" value="Search" /> </p> </fieldset> <% } %> <script src="../../Scripts/jquery-1.4.1.js" type="text/javascript"></script> <script type="text/javascript"> jQuery("#button1").click(function (e) { window.setInterval(refreshResult, 5000); }); function refreshResult() { jQuery("#divResult").load("/Home/Refresh"); } </script> <div id="divResult"> </div> </asp:Content> [HttpPost] public ActionResult Search(WebGLSQuery queryToCreate) { if (!ModelState.IsValid) return View("Search"); queryToCreate.Remote_Address = HttpContext.Request.ServerVariables["REMOTE_ADDR"]; Session["Result"] = null; SearchKeywordLines(queryToCreate); Thread.Sleep(15000); return View("Search"); }//Search() After button1 button is clicked the above script from Search web page runs Search() action in controller runs for longer period of time. I simulate this in testing by putting Thread.Sleep(15000); in Search()action. 5 sec. after Submit button was pressed, the above jQuery script calls Refresh() action in Home controller. public ActionResult Refresh() { ViewData["Result"] = DateTime.Now; return PartialView(); } Refresh() renders this partial <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" % <%= ViewData["Result"] % The problem is that in Internet Explorer 8 there is only one request to /Home/Refresh; in Firefox 3.6.3 all requests to /Home/Refresh are made but nothing is displayed on the web page. I would be grateful for helpful suggestions.

    Read the article

  • ASP.NET MVC 2 DropDownList not rendering

    - by Tomaszewski
    Hi, so I don't understand what I am doing wrong here. I want to populate a DropDownList inside the master page of my ASP.NET MVC 2 app. Projects.Master <div id="supaDiv" class="mainNav"> <% Html.DropDownList("navigationList"); %> </div> MasterController.cs namespace ProjectsPageMVC.Controllers.Abstracts { public abstract class MasterController : Controller { public MasterController() { List<SelectListItem> naviList = new List<SelectListItem>(); naviList.Add(new SelectListItem { Selected = true, Text = "AdvanceWeb", Value = "http://4168web/advanceweb/" }); naviList.Add(new SelectListItem { Selected = false, Text = " :: AdvanceWeb Admin", Value = "http://4168web/advanceweb/admin/admindefault.aspx" }); ViewData["navigationList"] = naviList; } } } ProjectsController namespace ProjectsPageMVC.Controllers { public class ProjectsController : MasterController { public ActionResult Index() { return View(); } } } The DropDownList is not even showing up in the DOM and I am at a loss as to what I am doing wrong.

    Read the article

  • ASP.NET MVC ,Maintaining Model State between Ajax requests

    - by Podders
    problem: On first full page request, my controller invokes an applicationServices Layer (Web Service Proxy to my business tier) in order to populate a collection of current services that is stored in my own controller base class property. This is then to be displayed within a view. Everything within the context of that controller has access to this "Services Collection". Now when i make further calls to the same action method via an AJAX Call, i obviously hitt a different instance of that controller meaning my services collection is empty. So other than re-getting the whole collection again, where would i store this collection so it gets persisted between ajax requests? Should i persist it as a seperate DomainModel Object, Session object?....as ViewData is not working for me obv. Excuse my MVC ignorance :) Any help would be greatly appreciated :)

    Read the article

  • ASP.NET MVC Authentication Cookie Not Being Retrieved

    - by Jamie Wright
    I am having a hard time implementing "Remember Me" functionality in an MVC application with a custom principal. I have boiled it down to ASP.NET not retrieving the authentication cookie for me. I have included a snaphot below from Google Chrome. Shows the results of Request.Cookies that is set within the controller action and placed in ViewData for the view to read. Notice that it is missing the .ASPXAUTH cookie Shows the results from the Chrome developer tools. You can see that .ASPXAUTH is included here. Does anyone know what the issue may be here? Why does ASP.NET not read this value from the cookie collection?

    Read the article

  • Unit Testing in ASP.NET MVC: Minimising the number of asserts per test

    - by Neil Barnwell
    I'm trying out TDD on a greenfield hobby app in ASP.NET MVC, and have started to get test methods such as the following: [Test] public void Index_GetRequest_ShouldReturnPopulatedIndexViewModel() { var controller = new EmployeeController(); controller.EmployeeService = GetPrePopulatedEmployeeService(); var actionResult = (ViewResult)controller.Index(); var employeeIndexViewModel = (EmployeeIndexViewModel)actionResult.ViewData.Model; EmployeeDetailsViewModel employeeViewModel = employeeIndexViewModel.Items[0]; Assert.AreEqual(1, employeeViewModel.ID); Assert.AreEqual("Neil Barnwell", employeeViewModel.Name); Assert.AreEqual("ABC123", employeeViewModel.PayrollNumber); } Now I'm aware that ideally tests will only have one Assert.xxx() call, but does that mean I should refactor the above to separate tests with names such as: Index_GetRequest_ShouldReturnPopulatedIndexViewModelWithCorrectID Index_GetRequest_ShouldReturnPopulatedIndexViewModelWithCorrectName Index_GetRequest_ShouldReturnPopulatedIndexViewModelWithCorrectPayrollNumber ...where the majority of the test is duplicated code (which therefore is being tested more than once and violates the "keep tests fast" advice)? That seems to be taking it to the extreme to me, so if I'm right as I am, what is the real-world meaning of the "one assert per test" advice?

    Read the article

  • fill data in dropdown box as per previous dropdown box data selected in aspnet mvc 1

    - by FosterZ
    hi, i'm buildin' an employee registration form in aspnet mvc, i have fields like "School" list in 1 dropdown box and "Department" list another, problem is i want to show Department list on change of School list, i have done followin' code: public ActionResult EmployeeCreate() { var getSchool = SchoolRepository.GetAllSchoolsInArray();//this gets school_id as value and school_name as text for dropdown box ViewData["SchoolsList"] = getSchool; return View(); } [AcceptVerbs(HttpVerbs.Post)] public ActionResult EmployeeCreate() { _employeeRepository.CreateEmployee(employeeToCreate); _employeeRepository.SaveToDb(); } Here is the View Html.DropDownList("SchoolLists") Html.DropDownList("DepartmentLists") now, how do i get the departments of selected school in dropdown boxes

    Read the article

  • ASP.net MVC [HandleError] not catching exceptions.

    - by Eric
    In two different application, one a custom the other the sample MVC application you get with a new VS2008 MVC project, [HandleError] is not catching exceptions. In the sample application I have: [HandleError] public class HomeController : Controller { public ActionResult Index() { ViewData["Message"] = "Welcome to ASP.NET MVC!"; throw new Exception(); return View(); } public ActionResult About() { return View(); } } which is just the default controller with an exception being thrown for testing. But it doesn't work. Instead of going to the default error.aspx page it shows the debug information in the browser. The problem first cropped up in a custom application I'm working on which led me to test it with the sample application. Thinking it had something to do with changes I made in the custom application, I left the sample application completely unchanged with the exception (yuck) of the throw in the index method. I'm stumped. What am I missing?

    Read the article

  • How to get the Focus on one of Buttons of JQuery Dialog on ASP.NET MVC page?

    - by Rita
    Hi I have an ASP.NET MVC page(Registration). On loading the page, i am calling Jquery Dialog with Agree and Disagree buttons on that Dialog. 1). How to set the focus to Agree button by default? 2). How to disable the X (Close) Mark that is on Top right corner? (So that i don't want the user to close that dialog simply). Code: $("#dialog-confirm").dialog({ closeOnEscape: false, autoOpen: <%= ViewData["autoOpen"] %>, height: 400, width: 550, modal: true, buttons: { 'Disagree': function() { location.href = "/"; }, 'Agree': function() { $(this).dialog('close'); $(this).focus(); } }, beforeclose: function(event, ui) { var i = event.target.id; var j = 0; } }); Appreciate your responses. Thanks

    Read the article

  • What am i doing wrong with asp.net-mvc dropdownlist?

    - by Pandiya Chendur
    I use a dropdownlist in one of my create.aspx but it some how doesnt seem to work... public IEnumerable<SelectListItem> FindAllMeasurements() { var mesurements = from mt in db.MeasurementTypes select new SelectListItem { Value = mt.Id.ToString(), Text= mt.Name }; return mesurements; } and my controller, public ActionResult Create() { var mesurementTypes = consRepository.FindAllMeasurements().AsEnumerable(); ViewData["MeasurementType"] = new SelectList(mesurementTypes,"Id","Name"); return View(); } and my create.aspx has this, <p> <label for="MeasurementTypeId">MeasurementType:</label> <%= Html.DropDownList("MeasurementType")%> <%= Html.ValidationMessage("MeasurementTypeId", "*") %> </p> When i execute this i got these errors, DataBinding: 'System.Web.Mvc.SelectListItem' does not contain a property with the name 'Id'.

    Read the article

  • Recommendation needed for text content, should I use text files or database?

    - by Jörgen
    I'm doing a web application in asp.net mvc. Now I'm at the point where I do alot of text info such as help texts, eula, privacy policy etc. I realized that I'm not sure what would the best way to store these texts. 1. Directly in the aspx page 2. In text files and then load the text via ViewData[] to the aspx file 3. In my sql database If use option 3 how would I then design the database e.g. eula = table x, privacypolicy=table y? I guess I just need some directions of what't the pros and cons with the options above.

    Read the article

  • ASP.NET MVC: Accessing ModelMetadata for items in a collection

    - by DanM
    I'm trying to write an auto-scaffolder for Index views. I'd like to be able to pass in a collection of models or view-models (e.g., IEnumerable<MyViewModel>) and get back an HTML table that uses the DisplayName attribute for the headings (th elements) and Html.Display(propertyName) for the cells (td elements). Each row should correspond to one item in the collection. When I'm only displaying a single record, as in a Details view, I use ViewData.ModelMetadata.Properties to obtain the list of properties for a given model. But what happens when the model I pass to the view is a collection of model or view-model objects and not a model or view-model itself? How do I obtain the ModelMetadata for a particular item in a collection?

    Read the article

  • ASP.NET MVC 2 form submit route issue

    - by Tomaszewski
    Hi, i'm having this issue, in ASP.NET MVC 2 where I'm adding a drop down list on the master page and filling it with data from an abstract master controller. When an option is selected an submit button clicked, it reroutes you to a new page. so lets say the page lives on http://domain.com/landingPage i'm on: http://domain.com/landingPage i select option and submit takes me to http://domain.com/landingPage/Projects/FramedPage i select again and now the post tries to go to: http://domain.com/landingPage/Projects/landingPage/Projects/FramedPage because of the action="" i have set on the form tag. Any ideas on how to go about this? MasterPage: <form method="get" action="landingPage/Projects/FramedPage"> <%= Html.DropDownList("navigationList")%> <input id="navSubmitBtn" class="btnBlue" type="submit" value="Take Me There" /> </form> Projects Controller public ActionResult FramedPage(string navigationList) { ViewData["navLink"] = navigationList; return View(); } The problem i am having is that if I am ON that page

    Read the article

  • How to get ID of EditorFor with nested viewmodels in asp.net mvc 2

    - by Luke
    So I have two nested view models, CreditCard - BillAddress. I have a view, "EditBilling", that has EditorFor(CreditCard). The CreditCard EditorTemplate has EditorFor(BillAddress), and the BillAddress EditorTemplate has EditorFor(BillState). The end result is a select list with id "CreditCard_BillAddress_BillState". I need to reference this in javascript, thus need to know the ID. In other situations, with non-nested ViewModels, I have used the following code: $('#<%= ViewData.ModelMetadata.PropertyName %>_BillState') The problem here is that the ModelMetadata.PropertyName property is only aware of the current property, not the parent(s). So I end up with the following: $('#BillAddress_BillState') How does one go about getting the client ID of nested strongly typed helpers? Thanks in advance.

    Read the article

  • Regex for extracting second level domain from FQDN?

    - by Bob
    I can't figure this out. I need to extract the second level domain from a FQDN. For example, all of these need to return "example.com": example.com foo.example.com bar.foo.example.com example.com:8080 foo.example.com:8080 bar.foo.example.com:8080 Here's what I have so far: Dim host = Request.Headers("Host") Dim pattern As String = "(?<hostname>(\w+)).(?<domainname>(\w+.\w+))" Dim theMatch = Regex.Match(host, pattern) ViewData("Message") = "Domain is: " + theMatch.Groups("domainname").ToString It fails for example.com:8080 and bar.foo.example.com:8080. Any ideas?

    Read the article

< Previous Page | 6 7 8 9 10 11 12 13 14 15 16  | Next Page >