M
Marcus
I have a problem maybe one of you could help me with. I've created a data
entry screen with lots of dynamically-created client-side controls. I
create HTML texboxes client-side by assigning a value to the td.innerHTML
property. The UI is done, and I now want to post back the user's changes
and update my business object in .NET. But when I postback, I can't see any
of my dynamically created HTML controls in VB .NET. How do I make them
visible?
I understand that in order to make my HTML controls visible to .NET on
postback, I have to include the runat='server' property. But when I include
this in my dynamically-created control, it works fine as long as there are
no variables in the declaration of the control. For example,
The following works fine -- I can see the value on postback in .NET by
typing request.item("fff"):
var abc = '<INPUT type="text" id="fff" runat='server' value="abc" >';
objTD.innerHTML = abc
And this works too -- No compile error, but I can't see the value on
postback:
var myID = "fff"
var abc = '<INPUT type="text" id="' + myID + '" value="abc" >';
objTD.innerHTML = abc
But I get a parse error telling me that + myID + is not a valid identifier
if I do this.
var myID = "fff"
var abc = '<INPUT type="text" id="' + myID + '" runat='server'
value="abc" >';
objTD.innerHTML = abc
Apparently, if you specify a runat='server' parameter, the .NET compiler
fully evaluates the value assigned to innerHTML at compile-time, rather than
at runtime, but it evaluates it at runtime if the runat parameter is not
there. Unless I want all of my TD declarations to have the same ID, I need
a way to change the ID for each field.
Question 1: Is there a way for me to dynamically create HTML controls that
have unique IDs that are visible to the server?
Question 2: If not, is there a better way to get my data, which currently
lives as a two-dimensional array in Javascript, from the client to the
server?
Sorry for the long post. Thanks for any thoughts or input you might have.
Marcus
entry screen with lots of dynamically-created client-side controls. I
create HTML texboxes client-side by assigning a value to the td.innerHTML
property. The UI is done, and I now want to post back the user's changes
and update my business object in .NET. But when I postback, I can't see any
of my dynamically created HTML controls in VB .NET. How do I make them
visible?
I understand that in order to make my HTML controls visible to .NET on
postback, I have to include the runat='server' property. But when I include
this in my dynamically-created control, it works fine as long as there are
no variables in the declaration of the control. For example,
The following works fine -- I can see the value on postback in .NET by
typing request.item("fff"):
var abc = '<INPUT type="text" id="fff" runat='server' value="abc" >';
objTD.innerHTML = abc
And this works too -- No compile error, but I can't see the value on
postback:
var myID = "fff"
var abc = '<INPUT type="text" id="' + myID + '" value="abc" >';
objTD.innerHTML = abc
But I get a parse error telling me that + myID + is not a valid identifier
if I do this.
var myID = "fff"
var abc = '<INPUT type="text" id="' + myID + '" runat='server'
value="abc" >';
objTD.innerHTML = abc
Apparently, if you specify a runat='server' parameter, the .NET compiler
fully evaluates the value assigned to innerHTML at compile-time, rather than
at runtime, but it evaluates it at runtime if the runat parameter is not
there. Unless I want all of my TD declarations to have the same ID, I need
a way to change the ID for each field.
Question 1: Is there a way for me to dynamically create HTML controls that
have unique IDs that are visible to the server?
Question 2: If not, is there a better way to get my data, which currently
lives as a two-dimensional array in Javascript, from the client to the
server?
Sorry for the long post. Thanks for any thoughts or input you might have.
Marcus