Hi all,
I have tapped into the Item_Created event of DataGrid to customize it a little more how I would like.
In the footer (If e.Item.ItemType = ListItemType.Footer Then)
I am adding two TextBoxes and a button, and I would like to validate the data in the textboxes when the button is clicked, and I would like to do this with javascript.
So, here is what I did:
However, the output html is not quite as I would expect or like
id="DG_Events__ctl4_addEvent"
but addEvent.uniqueId does not resolve to id="DG_Events__ctl4_addEvent" but simply addEvent as seen here:
onclick="validateAddEvent('addEvent','addDes' );"
ClientId resolves to the same thing.
I have a feeling that I am calling ClientId too soon? The other things are not being added yet to clientId?
Can anyone shed some light on why clientID and uniqueId are resolving to Id?
Thanks for you help
CJB
I have tapped into the Item_Created event of DataGrid to customize it a little more how I would like.
In the footer (If e.Item.ItemType = ListItemType.Footer Then)
I am adding two TextBoxes and a button, and I would like to validate the data in the textboxes when the button is clicked, and I would like to do this with javascript.
So, here is what I did:
Code:
''add the textbox
Dim addEvent As TextBox = New TextBox
addEvent.Rows = 2
addEvent.ID = "addEvent"
addEvent.Attributes.Add("onclick", "if (this.value == 'Enter the event') this.value = '';")
addEvent.Text = "Enter the event here"
e.Item.Cells(3).Controls.Add(addEvent)
''add the button
Dim addButton As Button = New Button
addButton.Text = "Add"
addButton.ID = "addButton"
AddHandler addButton.Click, AddressOf bnAddEvent
addButton.CommandName = "Button_clicked"
addButton.Attributes.Add("onclick", "validateAddEvent('" + addEvent.uniqueId + "','" + addDes.ClientId + "' );")
e.Item.Cells(5).Controls.Add(addButton)
However, the output html is not quite as I would expect or like
id="DG_Events__ctl4_addEvent"
but addEvent.uniqueId does not resolve to id="DG_Events__ctl4_addEvent" but simply addEvent as seen here:
onclick="validateAddEvent('addEvent','addDes' );"
ClientId resolves to the same thing.
I have a feeling that I am calling ClientId too soon? The other things are not being added yet to clientId?
Can anyone shed some light on why clientID and uniqueId are resolving to Id?
Thanks for you help
CJB