Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Button's click - pass values to the conroller method
Message
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
MVC
Titre:
Button's click - pass values to the conroller method
Versions des environnements
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01554918
Message ID:
01554918
Vues:
59
Hi everybody,

I am trying the following idea:

I want to invoke a controller's method on button's click and pass values from the control defined in that same view (but I am not using a form):

So, right now I have this code
 <label for="clientName">Client Name: </label>
        <input type =  "text" size =25 data-autocomplete="@Url.Action("QuickSearch", "Client")"  name ="searchClientName" />
        <div> 

              
          @*  <input type="button" value="Find / Refresh" id="ClientsSearch" data-url="@Url.Action("Client", "Client")" />*@
          <input type="button" value="Find / Refresh" id="ClientsSearch" onclick="location.href=@Url.Action("Client", "Client")" />
My idea is to somehow pass new route values to the action this way:
<input type="button" value="Find / Refresh" id="ClientsSearch" onclick="location.href=@Url.Action("Client", "Client", new {searchClientName =)" />
and here after = I need to somehow pass that searchClientName input box value.

So, I understand I can not do this inline, so I suspect I have to do this in java-script jquery and this is what I have as a sample:
$(function () {
    $('#ClientsSearch').click(function () {
    
// Here I somehow want to set the location.href - or what is the right way to send it here to controller and pass parameters correctly using that other control name?
      
//        $('#flexClients').flexOptions({ url: '/Client/Client/' }).flexReload();
        //$.ajax({
        //    url: $(this).data('url'),
        //    type: 'GET',
        //    cache: false,
        //    success: function (result) {
        //        $('#ClientsResults').html(result);
        //    }
        //});
        return false;
    });
});
If it's not broken, fix it until it is.


My Blog
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform