I need to put a search box & button within a Razor .cshtml file. I can't really get round it as the design calls for a search slap bang in the middle of some linked navigation.
Is it possible to add asp:TextBox & asp:ImageButton to Razor files? And can you create events to redirect to search page with querystring.
.NET Controls in Razor
Hi all,
I need to put a search box & button within a Razor .cshtml file. I can't really get round it as the design calls for a search slap bang in the middle of some linked navigation.
Is it possible to add asp:TextBox & asp:ImageButton to Razor files? And can you create events to redirect to search page with querystring.
Or is there a simpler way? :)
Adrian
Have a look at this topic: http://our.umbraco.org/forum/developers/razor/22305-ASPNET-Usercontrol-inside-Razor-script.
Jeroen
I created a user control like this and works fine.
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="SearchForm.ascx.cs"
Inherits="TPControls.usercontrols.SearchForm" %>
<div id="formsearch">
<span>
<input type="text" name="s" id="s" placeholder="Search" class="editbox_search" /></span>
<input type="image" class="button_search" src="/css/images/search_btn.gif" onclick="return searchForm();" />
</div>
<script type="text/javascript">
function searchForm() {
var s = document.getElementById("s").value;
if (s == "") {
alert('please enter text to search');
return;
}
var strUrl = "http://" + document.domain + "/Search.aspx?s=" + s;
window.location = strUrl;
return false;
}
</script>
is working on a reply...