Search code examples
asp.net-mvcroutelink

Asp.net MVC add textbox value to routelink


I am trying to learn asp.net MVC and having an issue to submit a textbox value to a model.

I have a text box in which users will type a number and when they hit the routelink the routelink will take the value from the textbox and assigns it to one of .Page item.

<%=Html.TextBox("PageIndex")%>
<%=Html.RouteLink("Search", "UpcomingEvent", 
    New With {.Page = "I want to put value of PageIndex textbox here"})%>

How can I assign the value of the textbox to .Page variable? Thanks for your time and help!


Solution

  • You can't do that because the RouteLink gets rendered on the server.

    If you want to construct a URL based on the user input without a postback, you'll need to do some client-side scripting (ie JavaScript).