gpt4 book ai didi

c# - 比较javascript中的两个字符串; ASP。净C#

转载 作者:太空宇宙 更新时间:2023-11-03 20:14:22 25 4
gpt4 key购买 nike

在 asp 页面上我创建了这个函数来检查两个字符串是否相等:

 <script type="text/javascript">
function ButtonClick(a, b)
{
if (a == b)
{
alert("Correct!");
}
else
{
alert("Wrong!");
}

}
</script>

然后,我创建了这个函数,我在页面加载时使用它来显示所有内容:

public void FillPageSpelling()
{
ArrayList videoList1 = new ArrayList();

if (!IsPostBack)
{
videoList1 = ConnectionClass.GetSpelling(1);
}
else
{
int i = Convert.ToInt32(DropDownList1.SelectedValue);
videoList1 = ConnectionClass.GetSpelling(i);
}
StringBuilder sb = new StringBuilder();
foreach (Spelling sp in videoList1)
{

sb.Append(
string.Format(
@"<table class='VideoTable'>

<tr>
<td align='center'><font face='Verdana'> <font size='3'>Level:</font> <font size='2'>{3}</font></font></td>
</tr>


<tr>

<td align='center'><font face='Verdana'> <font size='3'>Sentence:</font> <font size='2'>{1}</font></font></td>
</tr>


<tr>
<td align='center'><font size='3'>Sound:<audio controls><source src=sound/{2}></audio>
<font face='Verdana'> <font size='2'> </font> </font></td>

</tr>


<tr>



<tr><td align='center'><font face='Verdana'> <font size='3'>Write the word here: <input type=text name=TextBox1></font></font> </td> </tr>

<td><button name=btnCheck type=button onclick='ButtonClick(TextBox1.Text, lblWord.Text)'>Check</button> </td>
<td><button name=btnCheat type=button onclick='ButtonClick(TextBox1.Text, lblWord.Text)'>Cheat</button> </td>

</tr>

<tr>



<td align='center'><font face='Verdana'> <font size='3'>Word:</font> <font size='2'><asp:Label ID=lblWord runat=server>{4}</asp:Label></font></font></td>


</tr>


</br>


</table>", sp.SID, sp.Sentence, sp.Sound, sp.Level, sp.Word));
lblOutput.Text = sb.ToString();



}

好吧,原来我在这里犯了一个错误:<td><button name=btnCheck type=button onclick='ButtonClick(TextBox1.Text, lblWord.Text)'>Check</button> </td>

我将标签 lblWord 改为文本框 - TextBox2,这就是调用该函数的方式:

<input type=button value='Check' class='p-userButton' onClick='ButtonClick(document.getElementById(""TextBox1"").value, document.getElementById(""TextBox2"").value);'/>

最佳答案

JavaScript 函数没有类型参数。像这样尝试你的功能:

function ButtonClick(a, b)
{
if (a == b)
{
alert("Correct!");
}
else
{
alert("Wrong!");
}

}

关于c# - 比较javascript中的两个字符串; ASP。净C#,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17869538/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com