The part: ....
document.getElementById('<%= lstFieldList_TrajectType(0)%>').value
needs to be dynamic.
The filelist is filled on another place in the aspx code-behind.
Because it is unknown how many elements will be in this list, I have to get the index dynamically.
This works: (say for 5 indexes)
document.getElementById('<%= lstFieldList_TrajectType(0)%>').value
document.getElementById('<%= lstFieldList_TrajectType(1)%>').value
document.getElementById('<%= lstFieldList_TrajectType(2)%>').value
document.getElementById('<%= lstFieldList_TrajectType(3)%>').value
document.getElementById('<%= lstFieldList_TrajectType(4)%>').value
....
So I need the index in lstFieldList_TrajectType(0) changed from lstFieldList_TrajectType(0) to something like lstFieldList_TrajectType(' + intCount + ').value
where intCout is the index that runs thru an while wend loop.
But when I try to put in this I get errors. I have no clue how to solve this.
As you can see is the "Veldaam" the same in each line, due to the fact that the index is (0) in the code...
This should increment by one in every pass in the while wend loop but
var strInnerHTML = '<H1> Hallo ' + document.getElementById('txtName_TrajectType').value + ' !</H1>'
var intCount = 0;
while (intCount <= <%= lstFieldList_TrajectType.Count %>) {
var strFieldName = strFieldName = 'lstFieldList_TrajectType(' + intCount + ')';
var strInnerHTML = strInnerHTML + '</br> Veldnaam: ' + document.getElementById('<%= lstFieldList_TrajectType(' + intCount + ')%>').value
intCount++;
}
var strInnerHTML = '<H1> Hallo ' + document.getElementById('txtName_TrajectType').value + ' !</H1>'
var intCount = 0;
while (intCount <= 14) {
var strFieldName = strFieldName = 'lstFieldList_TrajectType(' + intCount + ')';
var strInnerHTML = strInnerHTML + '</br> Veldnaam: ' + document.getElementById('TrajectType9_Omschrijving_OMS_GRD_INQ').value;
intCount++;
The content of <%= lstFieldList_TrajectType(0)%> is showed corrct: 'TrajectType9_Omschrijving_OMS_GRD_INQ'; but this is the (0) element of the list. I need the rest to.
The While construction is working perfect, it's the part in the document.getElementById('<%= lstFieldList_TrajectType(0)%>').value
that causes the problem. This is an index that is to be set to the value of intCount when the while wend loop is passed. This index causes the content of the list to show.
What I am looking for is a way to inject the intCount value into the <%= lstFieldList_TrajectType(0)%> construct.
But when I change the code from <%= lstFieldList_TrajectType(0)%> to <%= lstFieldList_TrajectType(' + intCount + ')%> it fails.
I get an error: error BC30201: Expressie wordt verwacht (English: Expression expected)
Check the rendered script that: <%= lstFieldList_TrajectType(' + intCount + ')%> is generating 'lstFieldList_TrajectType' + intCount and that referencing is correct; i.e. not confusing id withname
Hi Fang,
I tried to copy/past your suggestions into my code.
Now I get the error: Fout: 'document.getElementById(...)' is leeg of geen object
(for those who don't read Dutch in English: Error: 'document.getElementById(...)' is empty or no object)
My question: What does document.getElementById('bar').innerHTML = strInnerHTML; do?
This is where ther erroro originates from...
( I use the IE F12 debugging function to see what happens...)
So this is the complete function:
function Submit_TrajectType()
{
if(document.getElementById ('txtName_TrajectType').value!='')
{
var jsVar_TrajectType = document.getElementById('txtName_TrajectType').value;
var hiddenControl = 'dnn_ctr509_VDW_CVS_Traject_Edit_inpHideTrajectType';
document.getElementById(hiddenControl).value = jsVar_TrajectType;
var strInnerHTML = '<H1> Hallo ' + document.getElementById('txtName_TrajectType').value + ' !</H1>'
var intCount = 0;
while (intCount < document.getElementsByName('lstFieldList_TrajectType').length) {
Hi Fang,
there is no link yet, this code is on my development computer.
I am developing a VB.Net application for a DotNetNuke portal so there is HTML and vb.net code behind.
The HTML code is about 1400 lines and the .aspx is about 6500 lines.....
So this is a bit much to copy/paste here.....
I did post the javascript function already, and I'll show you a part of the HTML and vb.net code down here:
HTML:
<div id="MaskedDiv" class ="MaskedDiv">
</div>
<div align="center">
<table cellpadding="2" cellspacing="2" class="style2" style="background-color: #CCCCCC">
<tr>
<td class="style2">
Controlevenster is nog in ontwikkeling!
</td>
</tr>
<tr>
<td class="style3">
Dit is het controlevenster om te zien welke gegevens in de achterliggende tabellen u hebt gewijzigd.
Deze functie is nog in ontwikkeling, maar er is al wel iets te zien:
Klik op de tekst TrajectType, Cliënt, TrajectDetail, Opdrachtgever of Relatie in het bovenstaande scherm, en er verschijnt een hulpscherm.
De gegevens kunt u hier gaan wijzigen.
</td>
</tr>
<tr>
<td class="style2">
<a href="javascript:void(0);" onclick="javascript:OpenModelPopup_TrajectType();">Klik hier om het laatst geopende hulpscherm te zien.</a>
</td>
</tr>
<tr>
<td id="tdDisplayName">
</td>
<td id="tdDisplay_TrajectType">
</td>
</tr>
</table>
</div>
CodeBehind: (part I)
Protected Sub PopUp_TrajectType(ByVal strPopup_Link As String)
Try
Try
strSQLTableNames = "Select Table_Name From Information_Schema.Tables where Table_Type = 'Base Table' and Table_Name like '%VDW_CVS%' Order By 'Table_Name'"
Dim dbConnectionTableNames As SqlConnection = New SqlConnection(ConfigurationSettings.AppSettings("SiteSqlServer"))
Dim dbCommandTableNames As SqlCommand = New SqlCommand(strSQLTableNames, dbConnectionTableNames)
Dim dbDataReaderTableNames As SqlDataReader
dbConnectionTableNames.Open()
dbDataReaderTableNames = dbCommandTableNames.ExecuteReader(CommandBehavior.CloseConnection)
'Read the VDW_CVS datatables from the database
'and determine the correct tablename for the selectionquery.
While dbDataReaderTableNames.Read
strFileName = dbDataReaderTableNames.GetString(0)
CodeBehind: (part II)
Try
Dim dbConnectionFieldNames As SqlConnection = New SqlConnection(ConfigurationSettings.AppSettings("SiteSqlServer"))
Dim dbCommandFieldNames As SqlCommand = New SqlCommand(strSQLFileNames, dbConnectionFieldNames)
Dim dbDataReaderFieldNames As SqlDataReader
dbConnectionFieldNames.Open()
dbDataReaderFieldNames = dbCommandFieldNames.ExecuteReader(CommandBehavior.CloseConnection)
lstFieldList_TrajectType.Clear()
lstShortFieldList_TrajectType.Clear()
While dbDataReaderFieldNames.Read
strSQLFieldName = dbDataReaderFieldNames.GetString(0)
strSQLShortFieldName = dbDataReaderFieldNames.GetString(0)
CodeBehind: (part III)
Try
Dim dbConnectionDDL As SqlConnection = New SqlConnection(ConfigurationSettings.AppSettings("SiteSqlServer"))
Dim dbCommandDDL As SqlCommand = New SqlCommand(strSQL, dbConnectionDDL)
dbConnectionDDL.Open()
Dim dbDataReaderDDL As SqlDataReader
dbDataReaderDDL = dbCommandDDL.ExecuteReader(CommandBehavior.CloseConnection)
'Read the records from the found database table int the selection dropdownlist.
'TAKE CARE; The file could be empty!
intPrimaryRecordFieldIndex = 0
lstFieldContentList_TrajectType.Clear()
lstKeepListNewContent_TrajectType.Clear()
While dbDataReaderDDL.Read
intPrimaryRecordFieldIndex = 0
While intPrimaryRecordFieldIndex < intCountMax
Dim strFieldType As String = dbDataReaderDDL.GetDataTypeName(intPrimaryRecordFieldIndex)
intPrimaryRecordFieldIndex = intPrimaryRecordFieldIndex + 1
End While
End While
strInnerHTML_TrajectType = "<input type = 'Text' id='" & lstFieldList_TrajectType(intPrimaryRecordFieldIndex) & "' name='" & lstFieldList_TrajectType(intPrimaryRecordFieldIndex) & "'/>"
strPopUp_TrajectType_FieldContent = String.Join("<br>", lstFieldContentList_TrajectType.ToArray())
strPopUp_TrajectType_FieldNewContent = String.Join("<br>", lstKeepListNewContent_TrajectType.ToArray())
If Not dbDataReaderDDL Is Nothing Then
dbDataReaderDDL.Close()
Public Sub TraceLog(ByVal strModule As String, ByVal strItem As String, ByVal strDetail As String, ByVal strResult As String)
Dim strIsLogged As String = System.Web.HttpContext.Current.Session("Traject_IsLogged")
Dim strTraceLog As String = System.Web.HttpContext.Current.Session("Traject_TraceLog")
txt_IsLogged.Text = strIsLogged
If strIsLogged.ToLower = "true" Then
Dim strDateTime As DateTime = Now()
intLogRecord = intLogRecord + 1
Dim writer As IO.StreamWriter = IO.File.AppendText(strTraceLog)
writer.WriteLine("Log#: " & intLogRecord & " Append: " & strDateTime & "; Module: " & strModule & strControl & "; Item: " & strItem & strControl & "; Detail: " & strDetail & "; Result: " & strResult)
writer.Close()
End If
End Sub
Bookmarks