自定义 HTML 帮助程序扩展中的 Jquery 从表单中选取值
我在我的 Razor 视图中使用了这个自定义助手。
@Html.Link("OpenewWindow", Constants.Value, new { k = Constants.k, Staff_ID = LoginHelper.GetLoggedInUser() }, new { id = "mytag", target="_blank" })
当我单击此链接时,它会打开一个新窗口,其中包含查询字符串 ConstantValue/Constants?=someValue&Staff_ID=UserLoggedName。
我想选择表单上的单选按钮选定值并传递选中的值在查询字符串中。
那么我在哪里可以在自定义 Helper 方法中使用 Jquery 函数从表单中选取值。
Custom Helper 方法采用这种参数。
public static IHtmlString Link(this HtmlHelper htmlHelper, string linkText, string baseUrl, object query, object htmlAttributes).
I have used this custom Helper in My Razor View.
@Html.Link("OpenewWindow", Constants.Value, new { k = Constants.k, Staff_ID = LoginHelper.GetLoggedInUser() }, new { id = "mytag", target="_blank" })
When I Click on this link it opens me a new window with the Querystrings ConstantValue/Constants?=someValue&Staff_ID=UserLoggedName.
I want to pick the radio button selected value on the form and pass the checked value in QueryString.
So where can I use Jquery function in my custom Helper method to pick the value from the form.
The Custom Helper method takes this kind of aurguments.
public static IHtmlString Link(this HtmlHelper htmlHelper, string linkText, string baseUrl, object query, object htmlAttributes).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你可以使用 javascript 来做到这一点。例如,您可以订阅链接的
click
事件,然后通过附加新的查询字符串参数来打开一个弹出窗口:如果您不需要使用 javascript,那么更简洁的方法是使用形式而不是链接。这样,所选单选按钮的值将自动发送。
You could use javascript to do that. For example you could subscribe to the
click
event of the link and then open a popup window by appending the new query string parameter:If you don't need to use javascript then a cleaner approach is to use a form instead of a link. This way the value of the selected radio button will automatically be sent.