0

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.

0

1 Answer 1

1

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") %>
Sign up to request clarification or add additional context in comments.

3 Comments

i dont understand how it might help me?
$.post("/Search/Search", queryString, callBackSearch, "_default"); i need to change something in my methode i think. i cant call an action from seacrch controller
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?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.