将Razor转换为ASPX [英] convert Razor to ASPX

查看:48
本文介绍了将Razor转换为ASPX的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将此代码转换为aspx?

how can i transform this code to aspx?

@Html.ActionLink("Create New", "Create")
@using (Html.BeginForm("SearchIndex","Movies",FormMethod.Get)){
     Genre: @Html.DropDownList("movieGenre", "All")
       Title: @Html.TextBox("SearchString")
     <input type="submit" value="Filter" />
    }

推荐答案

所有你需要知道上面代码的作用,发布你应该发布的内容能够做到这一点。



这里:

1.创建链接

2.后跟下拉列表,文本框和提交按钮

3.单击此提交按钮,您需要根据下拉类别搜索电影名称(写在文本框中)。



现在试试。
All you need to know what above code does, post which you should be able to do it.

Out here:
1. Create link is present
2. Followed by a dropdownlist, a textbox and a submit button
3. On click of this submit button, you need to search the movie name (written in the textbox) based on the dropdown category.

Try out now.


从一个转换到另一个的简单方法是运行此代码的剃刀视图,查看html源代码,然后将该html源代码复制/粘贴到新的asp.net视图中。此时你只需要将相关的html元素转换为适当的asp.net控件。
An easy way convert from one to the other is to run the razor view for this code, view the html source and then copy/paste that html source into your new asp.net view. At that point you just have to convert the relevant html elements into their appropriate asp.net controls.


如果你使用的是webforms,那么查看mvc示例是没有意义的,因为很少有简单的一对一的转换。您尚未提供有关数据来源的足够信息,并且控件以不同方式绑定到其数据。而不是转换,你真的在​​寻找重写。因此,没有必要查看需要重写的示例,只需尝试找到您正在做的事情的webforms示例,有大量关于简单表单的示例。



Looking at mvc examples is pointless if you're using webforms as there is rarely an easy one-to-one conversion. You haven't provided enough information on where the data comes from and the controls are bound to their data in different ways. Rather than "converting" you're really looking at re-writing. So there is no point looking at examples that you need to rewrite, just try and find webforms examples of what you're doing, there are loads of examples around simple forms.

<asp:Hyperlink Navigateurl="yourcreatepage.aspx" Text="Create" runat="server"/>
<form method="post" runat="server">
    Genre: <asp:Dropdownlist ID="ddlGenre" runat="server"/>
    Title: <asp:Textbox ID="txtSearchString" runat="server"/>
    <asp:Button ID="btnSubmit" Text="Filter" runat="server"/>
</form>





这只是用户界面,数据发生了什么或下拉列表的填充方式取决于您,您没有提供足够的信息来重现。就像我上面所说的那样,只是远离MVC示例。



That is just the UI though, what happens to the data or how the dropdown gets populated is up to you, you didn't provide enough info to reproduce. Like I said above though, just stay away from MVC examples.


这篇关于将Razor转换为ASPX的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆