【发布时间】:2018-07-07 15:46:32
【问题描述】:
我在 C# asp.net webforms 的代码后面有这个,它不会执行,从 VB.NET 文件转置。 VB Webform 执行得很好,从 Pre-Render 中找到处于编辑模式的控件。但是 C# 版本没有。
有人能指出问题所在吗?该代码应该在 EditMode 中找到 Telerik TextBox 的内容,并使用 TextBox 的文本更改标题。
VB.NET 代码
Private Sub FormView1_PreRender(sender As Object, e As EventArgs) Handles FormView1.PreRender
If FormView1.CurrentMode = FormViewMode.Edit Then
Dim ProductNameTextBox As Label = FormView1.FindControl("BannerLabel")
Dim StudentName As RadTextBox = FormView1.FindControl("FirstNameTxtBx")
Dim UpdateButton As Button = FormView1.FindControl("UpdateButton")
ProductNameTextBox.Text = "Edit " + StudentName.Text + "'s Profile"
UpdateButton.Text = "Update changes to " + StudentName.Text + "'s Profile"
End If
End Sub
C# 代码
private void FormView1_PreRender(object sender, EventArgs e)
{
if (FormView1.CurrentMode == FormViewMode.Edit)
{
Label ProductNameTextBox = FormView1.FindControl("BannerLabel") as Label;
RadTextBox StudentName = FormView1.FindControl("FirstNameTxtBx") as RadTextBox;
Button UpdateButton = FormView1.FindControl("UpdateButton") as Button;
ProductNameTextBox.Text = "Edit " + StudentName.Text + "'s Profile";
UpdateButton.Text = "Update changes to " + StudentName.Text + "'s Profile";
}
}
【问题讨论】:
标签: c# vb.net formview findcontrol vb.net-to-c#