简体   繁体   中英

request query convert from vb to c#

this code is made by vb,page name:main.aspx

when i type the url like that main.aspx?sStyle=0 it type word Yes in the page

and if i type the url like that main.aspx?sStyle=0 it type word No in the page

<%@ Page Language=VB Debug=true %>
<%
Dim sStyle

    If Request.QueryString("sStyle") = "0" Or Len(Request.QueryString("sStyle")) = 0 Then
        Me = 0
    ElseIf Request.QueryString("sStyle") = "1" Then
        Me = 1
    End If
%>

<%If sStyle = "0" Then%>
Yes
<%End If%>

<%If sStyle = "1" Then%>
No
<%End If%>

=========================================================

my question is how do i make the exact same page using c#

Regards

    <%@ Page Language="C#" Debug="true" %>

<% if(Request.QueryString["sStyle"] == "1")
{%>
Yes
<%}else{%>
No
<%}%>

试试这个: VBConversions

您可以使用条件运算符:

<%= (Request.QueryString["sStyle"] == "1") ? "Yes" : "no" %>
<%@ Page Language=VB Debug=true %>
<% Dim sStyle
    If Request.QueryString("sStyle") = "0" Or
       Len(Request.QueryString("sStyle")) = 0 Then 
        Me = 0 
    ElseIf Request.QueryString("sStyle") = "1" Then 
        Me = 1 
    End If 
%>
<%If sStyle = "0" Then%> Yes <%End If%>
<%If sStyle = "1" Then%> No <%End If%>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM