I am trying to write a web app that has a page that contains a table which lists people with the following columns
column1 - Text
column2 - Text
column3 - Textbox
column4 - Text
column5 - dropdownlist
column6 - Text
Each row has Text, Text, Textbox, Text, Dropdown, Text
There will be n number of people in the list.
This table is created dynamically in VB.net code.
How it should work
When a user types a particular character (maxlength = 1) in the textbox the dropdownlist needs to be visible otherwise not visible.
It would be inefficient to postback every time someone types in the textbox as there will be n number of people in the list.
Unless someone can tell me there is a way around that.
The other way I have thought to do it is to use htmlcontrols (Input for the text and select for the dropdownlist) with a runat=server attribute.
To make the select control visible or not the page contains javascript.
I prefer to use display instead of visible, thats just me.Code:function gohere(){ if (document.getElementById('Text1').value == 'L') {document.getElementById('Select1').style.display = 'none'} else {document.getElementById('Select1').style.display = ''} }
The code for creating the input box is
VB Code:
tbcCell = New TableCell Dim txtMarkBox As New System.Web.UI.HtmlControls.HtmlInputText txtMarkBox.ID = "Mark" & i.ToString txtMarkBox.EnableViewState = True txtMarkBox.MaxLength = 1 tbcCell.Controls.Add(txtMarkBox) tbrRow.Cells.Add(tbcCell)
How do I tell the input what javascript to call?
How do I associate a style class to the input (held in a CSS file)?
I have to declare the input this way because I have validation controls associated with the input.
I did have a VB.NET function which returns a string of the input control which has the style and onblur call but as it is not a control so I cannot associate a validation control with it.
Any help would be appreciatedVB Code:
Public Shared Function HTMLMarkText(ByVal strID As String) As String Dim strText As String strText = "<INPUT type=""text"" maxlength=""1"" runat=""server"" " & _ " class=""markbox"" onblur=""gohere();"" ID=""" & strID & """" & _ " name=""" & strID & """" Return strText End Function
I realise its a bit of a longwinded explanation.




Reply With Quote