I need to get textbox that exits in Formview inserttemplate via javascript.
Both return null:
$get('txtTitle');
document.getElementById("txtTitle");
The problem is that formview is not rendered on form load...
I need to get textbox that exits in Formview inserttemplate via javascript.
Both return null:
$get('txtTitle');
document.getElementById("txtTitle");
The problem is that formview is not rendered on form load...
As you stated, the formview contents are rendered on the server upon request rather than on page load. That said, try this code to access controls in the formview. Change the name of 'FormView' to match your unique control ID.
document.getElementById('<%=FormView.FindControl("txtTitle").ClientID%>');
If needed, Here are a few useful events you can use to register the javascript in the code behind if there are lifecycle considerations.
The ItemCreated event is raised after all rows are created in a FormView control. This can occur when the control is first rendered, or when the user navigates to another record. You can use this event to provide an event-handling method that performs a custom routine, such as adding to or modifying the contents of a row, whenever this event occurs.
Note: The ItemCreated event occurs before the FormView control is bound to data. To modify the value of a bound field, use the DataBound event.