views:

16

answers:

1

i have an image:

<img onclick="Search()" alt="searchPage" style="vertical-align: middle;" height="17px"
    src="../../Stylesheets/search.PNG" title="search" />

and javascript methode:

<script language="javascript" type="text/javascript">

    function Search() {
        alert("test-search");
        var searchText = $("#txtSearch").val();
        var queryString = "SearchText=" + searchText;
        $.post("/Search/Search", queryString, callBackSearch, "_default");
    }

</script>

how can i call action Search from SearchController? in my js methode its is jquery $.post is it? but i dont wanjt to use jQuery in my project.

please help me.

A: 

If you don't want to use any javascript you could create a simple form containing the textbox and a submit image button:

<% using (Html.BeginForm()) { %>
    <%= Html.TextBoxFor(x => x.TxtSearch) %>
    <input type="image" alt="searchPage" style="vertical-align: middle;" height="17px" src="../../Stylesheets/search.PNG" title="search" />
<% } %>

or if your view is not strongly typed as it should be you could use the following helper to generate the textbox:

<%= Html.TextBox("TxtSearch") %>
Darin Dimitrov
i dont understand how it might help me?
Ragims
$.post("/Search/Search", queryString, callBackSearch, "_default");i need to change something in my methode i think. i cant call an action from seacrch controller
Ragims
If I understand your question correctly you were looking for a way to POST data to a given controller action without using javascript. If this is not the case try explaining better what is your goal. `$.post` is used to send an AJAX request. Is this what you are after?
Darin Dimitrov