aCcodeMonkey
01-03-2003, 02:39 AM
Hi All It's me again.
Gotta problem with a mail distribution list management web form that I'm migrating to ASP.Net. The original form used ASP and the RDC.DataControl to populate the form objects via an XML Stream.
Originallythis was no problem as the client was using only IE. Now they require that the form function in both IE and NS7. Thus ASP.Net.
I have a Listbox webcontrol that can be populated either by Server-side Databinding:
cmbMailList.DataSource = oDS.Tables("DistGroup2Member").DefaultView
cmbMailList.DataTextField = "LongName"
cmbMailList.DataValueField = "ListValue"
cmbMailList.DataBind()
or
Client-Side DOM Script:
// add all selected list items from both selection objects
oSelectTarget=document.getElementById('cmbMailList');
var aFields = new Array('cmbMembers','cmbProspects');
for(i=0;i<2;i++){
var oSelectSource=document.getElementById(aFields[i]);
for(nSelectedIndex=(oSelectSource.options.length-1);nSelectedIndex>=0;nSelectedIndex--){
if(oSelectSource.options[nSelectedIndex].selected){
sSourceValue=(i==0?oSelectSource.options[nSelectedIndex].value+'|0': oSelectSource.options[nSelectedIndex].value+'|1')
sSourceText=(i==0?oSelectSource.options[nSelectedIndex].text+' (M)': oSelectSource.options[nSelectedIndex].text+' (P)');
oSelectTarget.options[oSelectTarget.length]=new Option(sSourceText,sSourceValue)
oSelectSource.remove(nSelectedIndex);
}
}
}
When I run the following server-side code:
'******************************************
'********** Problem Code ***************/
Dim sItem as Object
For Each sItem In cmbMailList.Items
' *** Debug Print ****
Response.write(sItem.Value.ToString() & "<BR>")
sIndexID=Left(sItem.Value.ToString(),(Len(sItem.Value.ToString())-2))
nSourceID=right(sItem.Value.ToString(),1)
sSQL="INSERT INTO DistGroup2Member " & _
"(MailGroupID,MemberID,Source) VALUES(" & _
sGrpIndexID & "," & sIndexID & "," & nSourceID & ")"
'bUpdateStatus = Execute_Sql(sSQL,1)
Next
'******************************************
'******************************************
Only the originally bound data is returned. No client-side changes are reflected
If I use server-side HTTPRequest code:
'******************************************
'********** Problem Code ***************/
Dim sItem as Object
For Each sItem In Request.Form("cmbMailList")
' *** Debug Print ****
Response.write(sItem.Value.ToString() & "<BR>")
sIndexID=Left(sItem.Value.ToString(),(Len(sItem.Value.ToString())-2))
nSourceID=right(sItem.Value.ToString(),1)
sSQL="INSERT INTO DistGroup2Member " & _
"(MailGroupID,MemberID,Source) VALUES(" & _
sGrpIndexID & "," & sIndexID & "," & nSourceID & ")"
'bUpdateStatus = Execute_Sql(sSQL,1)
Next
'******************************************
'******************************************
I get a comma separated String instead of a collection e.g. 207|0,231|0,238|0,237|0,246|0
I can parse the string but for large mailing lists this will really slow down the process.
I've attached the working file to this so you can really see what's going on with the form.
Basically I am trying to avoid round-tripping to populate the cmbMailList Object.
Gotta Love a Challenge.....
Gotta problem with a mail distribution list management web form that I'm migrating to ASP.Net. The original form used ASP and the RDC.DataControl to populate the form objects via an XML Stream.
Originallythis was no problem as the client was using only IE. Now they require that the form function in both IE and NS7. Thus ASP.Net.
I have a Listbox webcontrol that can be populated either by Server-side Databinding:
cmbMailList.DataSource = oDS.Tables("DistGroup2Member").DefaultView
cmbMailList.DataTextField = "LongName"
cmbMailList.DataValueField = "ListValue"
cmbMailList.DataBind()
or
Client-Side DOM Script:
// add all selected list items from both selection objects
oSelectTarget=document.getElementById('cmbMailList');
var aFields = new Array('cmbMembers','cmbProspects');
for(i=0;i<2;i++){
var oSelectSource=document.getElementById(aFields[i]);
for(nSelectedIndex=(oSelectSource.options.length-1);nSelectedIndex>=0;nSelectedIndex--){
if(oSelectSource.options[nSelectedIndex].selected){
sSourceValue=(i==0?oSelectSource.options[nSelectedIndex].value+'|0': oSelectSource.options[nSelectedIndex].value+'|1')
sSourceText=(i==0?oSelectSource.options[nSelectedIndex].text+' (M)': oSelectSource.options[nSelectedIndex].text+' (P)');
oSelectTarget.options[oSelectTarget.length]=new Option(sSourceText,sSourceValue)
oSelectSource.remove(nSelectedIndex);
}
}
}
When I run the following server-side code:
'******************************************
'********** Problem Code ***************/
Dim sItem as Object
For Each sItem In cmbMailList.Items
' *** Debug Print ****
Response.write(sItem.Value.ToString() & "<BR>")
sIndexID=Left(sItem.Value.ToString(),(Len(sItem.Value.ToString())-2))
nSourceID=right(sItem.Value.ToString(),1)
sSQL="INSERT INTO DistGroup2Member " & _
"(MailGroupID,MemberID,Source) VALUES(" & _
sGrpIndexID & "," & sIndexID & "," & nSourceID & ")"
'bUpdateStatus = Execute_Sql(sSQL,1)
Next
'******************************************
'******************************************
Only the originally bound data is returned. No client-side changes are reflected
If I use server-side HTTPRequest code:
'******************************************
'********** Problem Code ***************/
Dim sItem as Object
For Each sItem In Request.Form("cmbMailList")
' *** Debug Print ****
Response.write(sItem.Value.ToString() & "<BR>")
sIndexID=Left(sItem.Value.ToString(),(Len(sItem.Value.ToString())-2))
nSourceID=right(sItem.Value.ToString(),1)
sSQL="INSERT INTO DistGroup2Member " & _
"(MailGroupID,MemberID,Source) VALUES(" & _
sGrpIndexID & "," & sIndexID & "," & nSourceID & ")"
'bUpdateStatus = Execute_Sql(sSQL,1)
Next
'******************************************
'******************************************
I get a comma separated String instead of a collection e.g. 207|0,231|0,238|0,237|0,246|0
I can parse the string but for large mailing lists this will really slow down the process.
I've attached the working file to this so you can really see what's going on with the form.
Basically I am trying to avoid round-tripping to populate the cmbMailList Object.
Gotta Love a Challenge.....