/    Sign up×
Community /Pin to ProfileBookmark

document.getElementById(‘<%= lstFieldList_TrajectType(0)%>’).value dynamic index…

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.

Please advise.

Thanks,
Jos

to post a comment
JavaScript

19 Comments(s)

Copy linkTweet thisAlerts:
@JosRiauthorDec 10.2010 — This is a piece of the code:

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(0)%>').value
intCount++;
}


This is the result:

Hallo dfZV !

Veldnaam: DZcSD

Veldnaam: DZcSD

Veldnaam: DZcSD

Veldnaam: DZcSD

Veldnaam: DZcSD

Veldnaam: DZcSD

Veldnaam: DZcSD

Veldnaam: DZcSD

Veldnaam: DZcSD

Veldnaam: DZcSD

Veldnaam: DZcSD

Veldnaam: DZcSD

Veldnaam: DZcSD

Veldnaam: DZcSD

Veldnaam: DZcSD

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++;

}

does not work....

Please advice.

Thaks,

Jos
Copy linkTweet thisAlerts:
@FangDec 11.2010 — Check the Error Console!
[CODE]// less than, not equal
while (intCount < <&#37;= lstFieldList_TrajectType.Count %>) {[/CODE]
Copy linkTweet thisAlerts:
@JosRiauthorDec 11.2010 — Thanks Fang, but the problem is elsewhere.


var strInnerHTML = '<H1> Hallo ' + document.getElementById('txtName_TrajectType').value + ' !</H1>'
var[B] intCount [/B]= 0;
while (intCount <= 14) {
var strFieldName = strFieldName = 'lstFieldList_TrajectType(' + intCount + ')';
var strInnerHTML = strInnerHTML + '</br> Veldnaam: ' + document.getElementById('[B]TrajectType9_Omschrijving_OMS_GRD_INQ[/B]').value;
intCount++;

The content of <%= lstFieldList_TrajectType[B](0)[/B]%> is showed corrct: '[B]TrajectType9_Omschrijving_OMS_GRD_INQ[/B]'; 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[B](0)[/B]%>').value

that causes the problem. This is an index that is to be set to the value of [B] intCount [/B] 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[B](0)[/B]%> construct.

But when I change the code from <%= lstFieldList_TrajectType[B](0)[/B]%> to <%= lstFieldList_TrajectType[B](' + intCount + ')[/B]%> it fails.

I get an error: error BC30201: Expressie wordt verwacht (English: Expression expected)
Copy linkTweet thisAlerts:
@FangDec 11.2010 — Check the rendered script that: [I]<%= lstFieldList_TrajectType(' + intCount + ')%>[/I] is generating [I]'lstFieldList_TrajectType' + intCount[/I] and that referencing is correct; i.e. not confusing [I]id [/I]with[I]name[/I]
[CODE]<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title></title>

<script type="text/javascript">
window.onload=function() {
var strInnerHTML = '<H1> Hallo ' + document.getElementById('txtName_TrajectType').value + ' !</H1>'
var intCount = 0;
while (intCount < document.getElementsByName('lstFieldList_TrajectType').length) {
var strFieldName = strFieldName = 'lstFieldList_TrajectType(' + intCount + ')'; // What is this for?
var strInnerHTML = strInnerHTML + '</br> Veldnaam: ' + document.getElementById('lstFieldList_TrajectType' + intCount).value
intCount++;
}
document.getElementById('bar').innerHTML = strInnerHTML;
};
</script>

<style type="text/css">
body {
font-family:Verdana, Geneva, Arial, Helvetica, sans-serif;
font-size:0.8em;
}
</style>

</head>
<body>
<input type="text" id="txtName_TrajectType" value="foo">
<input type="text" id="lstFieldList_TrajectType0" value="boter" name="lstFieldList_TrajectType">
<input type="text" id="lstFieldList_TrajectType1" value="kaas" name="lstFieldList_TrajectType">
<input type="text" id="lstFieldList_TrajectType2" value="eieren" name="lstFieldList_TrajectType">
<div id="bar"></div>
</body>
</html>
[/CODE]
Perhaps only using [I]name [/I]and no [I]id[/I] would be simpler.
Copy linkTweet thisAlerts:
@JosRiauthorDec 11.2010 — 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 [B][COLOR="Red"]document.getElementById('bar').innerHTML = strInnerHTML;[/COLOR][/B] 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) {

var strFieldName = strFieldName = 'lstFieldList_TrajectType(' + intCount + ')';
var strInnerHTML = strInnerHTML + '</br> Veldnaam: ' + document.getElementById('lstFieldList_TrajectType' + intCount).value

intCount++;
}
[B][COLOR="Red"]document.getElementById('bar').innerHTML = strInnerHTML;[/COLOR][/B]
document.getElementById ('MaskedDiv').style.display='none';
document.getElementById ('ModalPopupDiv_TrajectType').style.display='none';
document.getElementById ('tdDisplayName').innerHTML = strInnerHTML;
}
else
{
alert ('Geef uw naam a.u.b.');
}
}
Copy linkTweet thisAlerts:
@FangDec 11.2010 — It was intended as an example of how it does work. Your code does not work because the referencing is incorrect. Check your [U]generated[/U] code
Copy linkTweet thisAlerts:
@JosRiauthorDec 11.2010 — Hi Fang, I found out what the ('BAR') is.....

Silly me.....

Just deleted this line because the 'BAR' has another name in my code.

But now I don't get any subsequent lines after the Namefield.

[B]Function code:[/B]

function Submit_TrajectType()

{

if(document.getElementById ('txtName_TrajectType').value!='')

{

var jsVar_TrajectType = document.getElementById('txtName_TrajectType').value;
var hiddenControl = '<%= inpHideTrajectType.ClientID %>';
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) {

var strFieldName = strFieldName = 'lstFieldList_TrajectType(' + intCount + ')';
var strInnerHTML = strInnerHTML + '</br> Veldnaam: ' + document.getElementById('lstFieldList_TrajectType' + intCount).value

intCount++;
}
document.getElementById ('MaskedDiv').style.display='none';
document.getElementById ('ModalPopupDiv_TrajectType').style.display='none';
document.getElementById ('tdDisplayName').innerHTML = strInnerHTML;
}
else
{
alert ('Geef uw naam a.u.b.');
}
}


[B]Output on screen:[/B]

Hallo dythj !

[B]Code in the debugger:[/B]

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) {

var strFieldName = strFieldName = 'lstFieldList_TrajectType(' + intCount + ')';
var strInnerHTML = strInnerHTML + '</br> Veldnaam: ' + document.getElementById('lstFieldList_TrajectType' + intCount).value

intCount++;
}
document.getElementById ('MaskedDiv').style.display='none';
document.getElementById ('ModalPopupDiv_TrajectType').style.display='none';
document.getElementById ('tdDisplayName').innerHTML = strInnerHTML;
}
else
{
alert ('Geef uw naam a.u.b.');
}
}
Copy linkTweet thisAlerts:
@JosRiauthorDec 11.2010 — Veldnaam Inhoud Wijzigen


TrajectType9_Omschrijving_OMS_GRD_INQ IRO Wajong input type = 'Text' id='TrajectType9_Omschrijving_OMS_GRD_INQ' name='Omschrijving'


TrajectType10_GrootboekRekening_INQ SOME VALUE input type = 'Text' id='TrajectType10_GrootboekRekening_INQ' name='GrootboekRekening'


TrajectType11_PlaatsingPeriode_INT_INQ 0 input type = 'Text' id='TrajectType11_PlaatsingPeriode_INT_INQ' name='PlaatsingPeriode'


TrajectType12_PlaatsingPeriodeEenheid_ISO_INQ ISOVALUE input type = 'Text' id='TrajectType12_PlaatsingPeriodeEenheid_ISO_INQ' name='PlaatsingPeriodeEenheid'


TrajectType13_TrajectDuur_DEC_INQ 0 input type = 'Text' id='TrajectType13_TrajectDuur_DEC_INQ' name='TrajectDuur'


TrajectType14_TrajectDuurEenheid_ISO_INQ ISOVALUE input type = 'Text' id='TrajectType14_TrajectDuurEenheid_ISO_INQ' name='TrajectDuurEenheid'


TrajectType15_PlanRetourPeriode_INT_INQ 0 input type = 'Text' id='TrajectType15_PlanRetourPeriode_INT_INQ' name='PlanRetourPeriode'


TrajectType16_PlanRetourPeriodeEenheid_ISO_INQ ISOVALUE input type = 'Text' id='TrajectType16_PlanRetourPeriodeEenheid_ISO_INQ' name='PlanRetourPeriodeEenheid'


TrajectType19_VerkoopPrijs_CLC_DEC_INQ 0.0000 input type = 'Text' id='TrajectType19_VerkoopPrijs_CLC_DEC_INQ' name='VerkoopPrijs'


TrajectType20_TFAanName_JaNee_INQ Ja/Nee input type = 'Text' id='TrajectType20_TFAanName_JaNee_INQ' name='TFAanName'


TrajectType31_TFToeleiding_JaNee_INQ Ja/Nee input type = 'Text' id='TrajectType31_TFToeleiding_JaNee_INQ' name='TFToeleiding'


TrajectType42_TFPlaatsing_JaNee_INQ Ja/Nee input type = 'Text' id='TrajectType42_TFPlaatsing_JaNee_INQ' name='TFPlaatsing'


TrajectType53_TFMutaties_JaNee_INQ Ja/Nee input type = 'Text' id='TrajectType53_TFMutaties_JaNee_INQ' name='TFMutaties'


TrajectType64_TFVervolg_JaNee_INQ Ja/Nee input type = 'Text' id='TrajectType64_TFVervolg_JaNee_INQ' name='TFVervolg'


Geef uw naam:


Verzenden
Copy linkTweet thisAlerts:
@FangDec 11.2010 — Can you give a link or associated html?
Copy linkTweet thisAlerts:
@JosRiauthorDec 11.2010 — 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:

[B]HTML:[/B]

<div id="MaskedDiv" class ="MaskedDiv">

</div>

<div id="ModalPopupDiv_TrajectType" class="ModalPopup">

<table width="900px" cellpadding="2" cellspacing="0" border="0" style="background-color: #CCCCCC">

<tr class="style4">

<td>

<input id="inpHideTrajectType" type="hidden" runat="server" />

<asp:TextBox ID="txtJSValueTrajectType" runat="server"></asp:TextBox>

</td>

<td>

<input type ="text" id="PopId_TrajectType" name="PopName_TrajectType" value=""/>

</td>

</tr>

<tr>

<td align="left" style="width: 25%; background-color:#003399; color :White; font-weight:bold"; valign="top">

TrajectType <%=TextBox_Traject9_TrajectType_DDL_LNK_GRD_CLR.Text %>

</td>

<td style="width: 25%;background-color:#003399; color :White; font-weight:bold;" align="right" valign="top">

<a href="javascript:void(0);" onclick="javascript:CloseModelPopup_TrajectType();" style ="color :White;">Sluiten</a>

</td>

<td style="width: 50%;background-color:#003399; color :White; font-weight:bold;" align="right" valign="top">

</td>

</tr>

<tr>

<td align="left" style="background-color:#003399; color :White; font-weight:bold"; valign="top">

Veldnaam

</td>

<td align="left" style="background-color:#003399; color :White; font-weight:bold"; valign="top">

Inhoud

</td>

<td align="left" style="background-color:#003399; color :White; font-weight:bold"; valign="top">

Wijzigen

</td>

</tr>

<% Dim intCountTrajectType As Integer = 0 %>

<% While intCountTrajectType < lstFieldList_TrajectType.Count %>

<tr>

<td>

<%= lstFieldList_TrajectType(intCountTrajectType) %>

</td>

<td>

<%= lstFieldContentList_TrajectType(intCountTrajectType) %>

</td>

<td>

<%= lstKeepListNewContent_TrajectType(intCountTrajectType) %>

</td>

<td>

<%= lstKeepListInnerHTML_TrajectType(intCountTrajectType) %>

</td>

</tr>

<% intCountTrajectType = intCountTrajectType + 1 %>

<% End While %>

<tr>

<td>

Geef uw naam:

<input type ="text" id="txtName_TrajectType" name="txtName_TrajectType" value=""/>

</td>

</tr>

<tr>

<td colspan ="2" align ="center">

<a href="javascript:void(0);" onclick="javascript:Submit_TrajectType();">Verzenden</a>

</td>

</tr>

<tr>

<td colspan ="2" align ="center">

</td>

</tr>

</table>

</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>
Copy linkTweet thisAlerts:
@JosRiauthorDec 11.2010 — [B]CodeBehind: (part I)[/B]

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'"

'================ Start TraceLog ================
strItem = "Datareaders: PopUp_TrajectType; START PopUp_TrajectType"
strDetail = "SQLTableNames: " & strSQLTableNames
strResult = "Go for: " & strPopup_Link
TraceLog(strModule, strItem, strDetail, strResult)
'================= End TraceLog =================

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)

'================ Start TraceLog ================
strItem = "Datareaders: PopUp_TrajectType; Find FileName"
strDetail = "FileName: " & strFileName
strResult = "Go for SQL FileName Build!"
TraceLog(strModule, strItem, strDetail, strResult)
'================= End TraceLog =================

If strFileName.Contains("TrajectType") Then

'================ Start TraceLog ================
strItem = "Datareaders: PopUp_TrajectType; Find FileName"
strDetail = "Find: TrajectType"
strResult = "FileName: " & strFileName
TraceLog(strModule, strItem, strDetail, strResult)
'================= End TraceLog =================

'Build the selectionquery to list.
strSQLFileNames = "Select Column_Name From Information_Schema.Columns where Table_Name = '" & strFileName & "'"

'================ Start TraceLog ================
strItem = "Datareaders: PopUp_TrajectType; Build strSQLFileNames"
strDetail = "strSQLFileNames: " & strSQLFileNames
strResult = "FileName: " & strFileName
TraceLog(strModule, strItem, strDetail, strResult)
'================= End TraceLog =================

Exit While
Else

'================ Start TraceLog ================
strItem = "Datareaders: PopUp_TrajectType; ### Not found: TrajectType"
strDetail = "strSQLFileNames: " & strSQLFileNames
strResult = "###"
TraceLog(strModule, strItem, strDetail, strResult)
'================= End TraceLog =================

End If
End While
If Not dbDataReaderTableNames Is Nothing Then
dbDataReaderTableNames.Close()

'================ Start TraceLog ================
strItem = "Datareaders: PopUp_TrajectType; ### WARNING!!"
strDetail = "Empty table!"
strResult = "###"
TraceLog(strModule, strItem, strDetail, strResult)
'================= End TraceLog =================

End If
Catch Exc As Exception 'Module failed to load
mErrMessage += " " & Exc.Message

'================ Start TraceLog ================
strItem = "### Error: Datareaders: PopUp_TrajectType; FileName"
strDetail = "strSQLFileNames: " & strSQLFileNames
strResult = "### ERROR: " & mErrMessage
TraceLog(strModule, strItem, strDetail, strResult)
'================= End TraceLog =================

End Try
Copy linkTweet thisAlerts:
@JosRiauthorDec 11.2010 — [B]CodeBehind: (part II)[/B]

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)

'================ Start TraceLog ================
strItem = "Datareaders: PopUp_TrajectType; Find FieldName"
strDetail = "FileName: " & strFileName
strResult = "Find Field: " & strSQLFieldName
TraceLog(strModule, strItem, strDetail, strResult)
'================= End TraceLog =================

If strSQLFieldName.ToUpper.Contains("_PPP") Then

'================ Start TraceLog ================
strItem = "Datareaders: PopUp_TrajectType; Get FieldName [_PPP]"
strDetail = "SQLFileNames: " & strSQLFileNames
strResult = "Find [_PPP]Field: " & strSQLFieldName
TraceLog(strModule, strItem, strDetail, strResult)
'================= End TraceLog =================

strPopUp_TrajectType_Key = strSQLFieldName
End If
If strSQLFieldName.ToUpper.Contains("_INQ") Then

'================ Start TraceLog ================
strItem = "Datareaders: PopUp_TrajectType; Get FieldName [_INQ]"
strDetail = "SQLFileNames: " & strSQLFileNames
strResult = "Find [_INQ]Field: " & strSQLFieldName
TraceLog(strModule, strItem, strDetail, strResult)
'================= End TraceLog =================

lstFieldList_TrajectType.Add(strSQLFieldName)
lstShortFieldList_TrajectType.Add(GetShortObjectName(strSQLShortFieldName))
End If
End While
intCountMax = lstFieldList_TrajectType.Count
Select Case lstFieldList_TrajectType.Count
Case 0
strSQLFieldNames = "*"
strSQL = "select " & strSQLFieldNames & " from " & strFileName
strPopUp_TrajectType_FieldList = "Empty"
Case 1
strSQLFieldNames = lstFieldList_TrajectType(0)
strSQL = "select distinct " & strSQLFieldNames & " from " & strFileName & " where " & strPopUp_TrajectType_Key & " like '%" & strPopup_Link & "'"
strPopUp_TrajectType_FieldList = GetShortObjectName(strSQLFieldNames)
Case Else
strSQLFieldNames = String.Join(", ", lstFieldList_TrajectType.ToArray())
strSQL = "select distinct " & strSQLFieldNames & " from " & strFileName & " where " & strPopUp_TrajectType_Key & " like '%" & strPopup_Link & "'"
strPopUp_TrajectType_FieldList = String.Join("<br>", lstShortFieldList_TrajectType.ToArray())
End Select

'================ Start TraceLog ================
strItem = "Datareaders: PopUp_TrajectType; Found SelectionFields"
strDetail = "## [_INQ]-fields: " & lstFieldList_TrajectType.Count.ToString
strResult = "FieldNames: " & strSQLFieldNames
TraceLog(strModule, strItem, strDetail, strResult)
'================= End TraceLog =================

'================ Start TraceLog ================
strItem = "Datareaders: PopUp_TrajectType; Create SQL"
strDetail = "Create strSQL: " & strSQL
strResult = "DONE!"
TraceLog(strModule, strItem, strDetail, strResult)
'================= End TraceLog =================

If Not dbDataReaderFieldNames Is Nothing Then
dbDataReaderFieldNames.Close()

'================ Start TraceLog ================
strItem = "Datareaders: PopUp_TrajectType; ### WARNING!!"
strDetail = "Empty table!"
strResult = "###"
TraceLog(strModule, strItem, strDetail, strResult)
'================= End TraceLog =================

End If
Catch Exc As Exception 'Module failed to load
mErrMessage += " " & Exc.Message

'================ Start TraceLog ================
strItem = "### Error: Datareaders: PopUp_TrajectType; FieldName"
strDetail = "TrajectType_TableNames: " & strSQLTableNames
strResult = "### ERROR: " & mErrMessage
TraceLog(strModule, strItem, strDetail, strResult)
'================= End TraceLog =================

End Try
Copy linkTweet thisAlerts:
@JosRiauthorDec 11.2010 — [B]CodeBehind: (part III)[/B]

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)

'================ Start TraceLog ================
strItem = "Datareaders: PopUp_TrajectType; SQL_INQ"
strDetail = "Get TrajectType_FieldContent"
strResult = "CountMax: " & intCountMax.ToString
TraceLog(strModule, strItem, strDetail, strResult)
'================= End TraceLog =================

'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)

'================ Start TraceLog ================
strItem = "Datareaders: PopUp_TrajectType"
strDetail = "Count# " & intPrimaryRecordFieldIndex.ToString & " Of " & intCountMax.ToString
strResult = "TrajectType_FieldType: " & strFieldType
TraceLog(strModule, strItem, strDetail, strResult)
'================= End TraceLog =================

Select Case strFieldType
Case "varchar"
strSQLFieldContent = " " & GetShortObjectName(dbDataReaderDDL.GetString(intPrimaryRecordFieldIndex))
Case "int"
strSQLFieldContent = " " & GetShortObjectName(dbDataReaderDDL.GetInt32(intPrimaryRecordFieldIndex))
Case "decimal"
strSQLFieldContent = " " & GetShortObjectName(dbDataReaderDDL.GetDecimal(intPrimaryRecordFieldIndex))
Case "datetime"
strSQLFieldContent = " " & GetShortObjectName(dbDataReaderDDL.GetDateTime(intPrimaryRecordFieldIndex))
Case "boolean"
strSQLFieldContent = " " & GetShortObjectName(dbDataReaderDDL.GetBoolean(intPrimaryRecordFieldIndex))
Case "money"
strSQLFieldContent = " " & GetShortObjectName(dbDataReaderDDL.GetDecimal(intPrimaryRecordFieldIndex))
Case Else
strSQLFieldContent = " " & GetShortObjectName(dbDataReaderDDL.GetString(intPrimaryRecordFieldIndex))
Select Case dbDataReaderDDL.GetString(intPrimaryRecordFieldIndex)
Case dbDataReaderDDL.GetString(intPrimaryRecordFieldIndex).ToLower.Contains("_mail")
'strSQLFieldContent = "<a href=mailto:" & dbDataReaderDDL.GetString(intPrimaryRecordFieldIndex) & "></a>"
Case dbDataReaderDDL.GetString(intPrimaryRecordFieldIndex).ToLower.Contains("_url")
'strSQLFieldContent = "<a href=http://" & dbDataReaderDDL.GetString(intPrimaryRecordFieldIndex) & "></a>"
End Select
End Select
lstFieldContentList_TrajectType.Add(strSQLFieldContent)
lstKeepListNewContent_TrajectType.Add("<input type = 'Text' id='" & lstFieldList_TrajectType(intPrimaryRecordFieldIndex) & "' name='" & lstShortFieldList_TrajectType(intPrimaryRecordFieldIndex) & "'/>")
lstKeepListInnerHTML_TrajectType.Add("input type = 'Text' id='" & lstFieldList_TrajectType(intPrimaryRecordFieldIndex) & "' name='" & lstShortFieldList_TrajectType(intPrimaryRecordFieldIndex) & "'")

'================ Start TraceLog ================
strItem = "Datareaders: PopUp_TrajectType"
strDetail = "strSQLFieldName: " & lstFieldList_TrajectType(intPrimaryRecordFieldIndex)
strResult = "strSQLFieldContent: " & strSQLFieldContent
TraceLog(strModule, strItem, strDetail, strResult)
'================= End TraceLog =================

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()

'================ Start TraceLog ================
strItem = "Datareaders: PopUp_TrajectType; ### WARNING!!"
strDetail = "Empty table!"
strResult = "###"
TraceLog(strModule, strItem, strDetail, strResult)
'================= End TraceLog =================

End If
Catch Exc As Exception 'Module failed to load
mErrMessage += " " & Exc.Message

'================ Start TraceLog ================
strItem = "### Error: Datareaders: PopUp_TrajectType; SelectionList"
strDetail = "strSQL: " & strSQL
strResult = "### ERROR: " & mErrMessage
TraceLog(strModule, strItem, strDetail, strResult)
'================= End TraceLog =================

End Try
Catch Exc As Exception 'Module failed to load
mErrMessage += " " & Exc.Message

'================ Start TraceLog ================
strItem = "### Error: Datareaders: PopUp_TrajectType"
strDetail = ""
strResult = "### ERROR" & mErrMessage
TraceLog(strModule, strItem, strDetail, strResult)
'================= End TraceLog =================

End Try

'================ Start TraceLog ================
strItem = "Datareaders: PopUp_TrajectType; End PopUp_TrajectType"
strDetail = ""
strResult = "DONE!"
TraceLog(strModule, strItem, strDetail, strResult)
'================= End TraceLog =================

End Sub
Copy linkTweet thisAlerts:
@JosRiauthorDec 11.2010 — 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
Copy linkTweet thisAlerts:
@JosRiauthorDec 11.2010 — The origin of the data in the javascript can be found in [B]CodeBehind: (part III)[/B].

[B]Look for the part:[/B]

Select Case strFieldType

Case "varchar"

strSQLFieldContent = " " & GetShortObjectName(dbDataReaderDDL.GetString(intPrimaryRecordFieldIndex))

Case "int"

strSQLFieldContent = " " & GetShortObjectName(dbDataReaderDDL.GetInt32(intPrimaryRecordFieldIndex))

Case "decimal"

strSQLFieldContent = " " & GetShortObjectName(dbDataReaderDDL.GetDecimal(intPrimaryRecordFieldIndex))

Case "datetime"

strSQLFieldContent = " " & GetShortObjectName(dbDataReaderDDL.GetDateTime(intPrimaryRecordFieldIndex))

Case "boolean"

strSQLFieldContent = " " & GetShortObjectName(dbDataReaderDDL.GetBoolean(intPrimaryRecordFieldIndex))

Case "money"

strSQLFieldContent = " " & GetShortObjectName(dbDataReaderDDL.GetDecimal(intPrimaryRecordFieldIndex))

Case Else

strSQLFieldContent = " " & GetShortObjectName(dbDataReaderDDL.GetString(intPrimaryRecordFieldIndex))

Select Case dbDataReaderDDL.GetString(intPrimaryRecordFieldIndex)

Case dbDataReaderDDL.GetString(intPrimaryRecordFieldIndex).ToLower.Contains("_mail")

'strSQLFieldContent = "<a href=mailto:" & dbDataReaderDDL.GetString(intPrimaryRecordFieldIndex) & "></a>"

Case dbDataReaderDDL.GetString(intPrimaryRecordFieldIndex).ToLower.Contains("_
url")

'strSQLFieldContent = "<a href=http://" & dbDataReaderDDL.GetString(intPrimaryRecordFieldIndex) & "></a>"

End Select

End Select

lstFieldContentList_TrajectType.Add(strSQLFieldContent)

lstKeepListNewContent_TrajectType.Add("<input type = 'Text' id='" & lstFieldList_TrajectType(intPrimaryRecordFieldIndex) & "' name='" & lstShortFieldList_TrajectType(intPrimaryRecordFieldIndex) & "'/>")

lstKeepListInnerHTML_TrajectType.Add("input type = 'Text' id='" & lstFieldList_TrajectType(intPrimaryRecordFieldIndex) & "' name='" & lstShortFieldList_TrajectType(intPrimaryRecordFieldIndex) & "'")

'================ Start TraceLog ================

strItem = "Datareaders: PopUp_TrajectType"

strDetail = "strSQLFieldName: " & lstFieldList_TrajectType(intPrimaryRecordFieldIndex)

strResult = "strSQLFieldContent: " & strSQLFieldContent

TraceLog(strModule, strItem, strDetail, strResult)

'================= End TraceLog =================

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())
Copy linkTweet thisAlerts:
@criterion9Dec 12.2010 — The only needed parts are the [B][I]generated html code[/I][/B] (view source in a browser).
Copy linkTweet thisAlerts:
@FangDec 12.2010 — I did post the javascript function already[/QUOTE]We need to see the client side script and html (generated code). You have only given the server scripts.
Copy linkTweet thisAlerts:
@JosRiauthorDec 12.2010 — Hi Fang,

I posted the clientside scripts in #8......

Unless you need other code?

Please explain.

Cheers,

Jops
Copy linkTweet thisAlerts:
@FangDec 12.2010 — What errors are you getting in the Error Console?
×

Success!

Help @JosRi spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.29,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...