I have this in the Code Behind of a C# asp.net webforms that will not execute, transposed from a VB.NET File. The VB Webform executes it fine, finding the controls in edit mode from Pre-Render. However the C# version does not.
Would someone be able to point out the what is wrong? The code is supposed to find the Telerik TextBox contents within the EditMode and change the title with the TextBox's text.
VB.NET Code
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# Code
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";
}
}