www.webdeveloper.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 20

Thread: document.getElementById('<%= lstFieldList_TrajectType(0)%>').value dynamic index...

Hybrid View

  1. #1
    Join Date
    Dec 2010
    Posts
    13

    Unhappy 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

  2. #2
    Join Date
    Dec 2010
    Posts
    13
    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

  3. #3
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    Check the Error Console!
    Code:
    // less than, not equal
     while (intCount < <&#37;= lstFieldList_TrajectType.Count %>) {

  4. #4
    Join Date
    Dec 2010
    Posts
    13

    More info on this.....

    Thanks Fang, but the problem is elsewhere.


    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)

  5. #5
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    Check the rendered script that: <%= lstFieldList_TrajectType(' + intCount + ')%> is generating 'lstFieldList_TrajectType' + intCount and that referencing is correct; i.e. not confusing id withname
    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>
    Perhaps only using name and no id would be simpler.
    Last edited by Fang; 12-11-2010 at 06:27 AM.

  6. #6
    Join Date
    Dec 2010
    Posts
    13

    Next part of the puzzle..

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

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

    intCount++;
    }
    document.getElementById('bar').innerHTML = strInnerHTML;
    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.');
    }
    }

  7. #7
    Join Date
    Dec 2010
    Posts
    13

    One step further...

    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.

    Function code:
    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.');
    }
    }

    Output on screen:
    Hallo dythj !

    Code in the debugger:
    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.');
    }
    }

  8. #8
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    It was intended as an example of how it does work. Your code does not work because the referencing is incorrect. Check your generated code

  9. #9
    Join Date
    Dec 2010
    Posts
    13

    More info: Screendump with controltext

    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

  10. #10
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    Can you give a link or associated html?

  11. #11
    Join Date
    Dec 2010
    Posts
    13

    Link or associated HTML...

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

  12. #12
    Join Date
    Dec 2010
    Posts
    13

    and CodeBehind.... (partI)

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

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

  13. #13
    Join Date
    Dec 2010
    Posts
    13

    and CodeBehind.... (part II)

    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)

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

  14. #14
    Join Date
    Dec 2010
    Posts
    13

    and CodeBehind.... (part III)

    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)

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

  15. #15
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    I did post the javascript function already
    We need to see the client side script and html (generated code). You have only given the server scripts.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles