如何将输入无线电值输入c# ?

时间:2022-06-21 15:09:54

can you tell me whats bad? I need only check on button select language to continue on next website.

你能告诉我什么不好吗?我只需要检查按钮选择语言继续下一个网站。

HTML

HTML

<asp:Content ID="BodyContent" ContentPlaceHolderID="BodySite" runat="server">
<h1>Výběr jazyka:</h1>
<p>Choose language | Sprachauswahl</p>
<form method="post" action="index.aspx">
<div class="checkbox-test">
    <table style="border-spacing: 5px; border-collapse: separate;">
        <tr>
            <td>
                <input type="radio" name="check_lang" id="check_cz" class="css-checkbox" value="cz" />
                <label for="check_cz" class="css-label"><img src="http://terquil.cz/images/cz.png" class="img-flag" alt="CZ" /></label>
            </td>
            <td><h2>CZ</h2></td>
        </tr>
        <tr>
            <td>
                <input type="radio" name="check_lang" id="check_en" class="css-checkbox" value="en" />
                <label for="check_en" class="css-label"><img src="http://terquil.cz/images/uk.png" class="img-flag" alt="EN" /></label>

            </td>
            <td><h2>EN</h2></td>
        </tr>
        <tr>
            <td>
                <input type="radio" name="check_lang" id="check_de" class="css-checkbox" value="de" />
                <label for="check_de" class="css-label"><img src="http://terquil.cz/images/de.png" class="img-flag" alt="DE" /></label>
            </td>
            <td><h2>DE</h2></td>
        </tr>
    </table> 
</div>
<input Type="submit" id="language_btn" VALUE="Pokračovat | Continue | Andere" >
</form>

C# (i tried this but dont work)

c#(我尝试了但没有成功)

protected void submit(object sender, EventArgs e)
{
    string cz = "cz";
    string de = "de";
    string en = "en";

    if (Request.Form["check_lang"] != null)
    {
        string selectLanguage = Request.Form["check_lang"].ToString();

        if (selectLanguage == cz)
            Response.Redirect("http://terquil.cz/cs/index.aspx");
        if (selectLanguage == en)
            Response.Redirect("http://terquil.cz/en/index.aspx");
        if (selectLanguage == de)
            Response.Redirect("http://terquil.cz/cs/index.aspx");
    }
}

CSS group objects:

CSS组对象:

input[type=radio].css-checkbox {
      position:absolute; 
      z-index:-1000; 
      left:-1000px; 
      overflow: hidden; 
      clip: rect(0 0 0 0); 
      height:1px; 
      width:1px; 
      margin:-1px; 
      padding:0; 
      border:0;
}

input[type=radio].css-checkbox + label.css-label {
    padding-left:37px;
    height:32px; 
    display:inline-block;
    line-height:32px;
    background-repeat:no-repeat;
    background-position: 0 0;
    font-size:32px;
    vertical-align:middle;
    cursor:pointer;
}

input[type=radio].css-checkbox:checked + label.css-label {
    background-position: 0 -32px;
}

label.css-label {
    background-image:url(http://csscheckbox.com/checkboxes/u/csscheckbox_c1a4f40d98f1c23d1ad84d2af9c314be.png);
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

I need make only that if someone select radio for his specify language and click on submit button so he will redirect to specify html page for his language.

我只需要做的是,如果有人为他的指定语言选择了广播,然后点击submit按钮,他就会重定向到为他的语言指定html页面。

1 个解决方案

#1


0  

Either use runat="server" to access it in c# code
Or use javascript, on change event of radio button you can store value in a hidden field which will be accessible into your c# code.

在c#代码中使用runat="服务器"访问它,或者使用javascript,在更改事件的单选按钮时,可以将值存储在隐藏字段中,该字段将可访问到c#代码中。

  $(document).ready(function(){
   $('#rdbEnglish').click(function(){
      $('#hdn').val('English');
   });

#1


0  

Either use runat="server" to access it in c# code
Or use javascript, on change event of radio button you can store value in a hidden field which will be accessible into your c# code.

在c#代码中使用runat="服务器"访问它,或者使用javascript,在更改事件的单选按钮时,可以将值存储在隐藏字段中,该字段将可访问到c#代码中。

  $(document).ready(function(){
   $('#rdbEnglish').click(function(){
      $('#hdn').val('English');
   });