Dynamic Html With Runat=Server Attribute

P

pbd22

Hi.

I am using a javascript file to populate a good chunk of my web page
with HTML.

I want to add the runat=server attribute to some of the tags but now
realize that I won't be able to access the elements until after the
generated code loads so, when the page compiles, the compiler
complains that this.X does not exist (of course, because X will not be
there until the source is generated).

How is this done?

Thanks.
 
S

Scott M.

pbd22 said:
Hi.

I am using a javascript file to populate a good chunk of my web page
with HTML.

I want to add the runat=server attribute to some of the tags but now
realize that I won't be able to access the elements until after the
generated code loads so, when the page compiles, the compiler
complains that this.X does not exist (of course, because X will not be
there until the source is generated).

How is this done?

Thanks.

It's not that you'll have to wait for the page to load, it's that the server
controls won't be compiled ahead of time. In my experience, what you are
trying to do isn't done. Usually, you make the controls and manipulate the
DOM with JavaScript, you don't use JavaScript to create server-side
controls.

-Scott
 
P

Patrice

I'm not sure to understand your design.

Either you are confusing what works where (if you meant you want to create
client side HTML tags with a runat="server" attribute). The principle is
that a runat="server" tag creates an object that allows to ease server side
programming. Ultimately this is just rendered as HTML code to the browser.
The browser doesn't known at all how the markup was created (and never how
the markup was changed client side, it just gets values posted inside
fields)...

Else you can just use the ClientID property to generate javascript code
(server side) that will use the dynamically generated control.

Some more details could be usefull as well as you preferred language (in
case you would need a code snippet to see if we are on the right track about
what you are trying to do).
 
P

pbd22

I'm not sure to understand your design.

Either you are confusing what works where (if you meant you want to create
client side HTML tags with a runat="server" attribute). The principle is
that a runat="server" tag creates an object that allows to ease server side
programming. Ultimately this is just rendered as HTML code to the browser..
The browser doesn't known at all how the markup was created (and never how
the markup was changed client side, it just gets values posted inside
fields)...

Else you can just use the ClientID property to generate javascript code
(server side) that will use the dynamically generated control.

Some more details could be usefull as well as you preferred language (in
case you would need a code snippet to see if we are on the right track about
what you are trying to do).

OK, thanks.

The big picture is this:

I have a datagrid that is rendered completely in Javascript (I
inherited it and, to date, there are no plans to change this design).

The JS-rendered datagrid has fields Number, File, & Status

When the user clicks "upload" the Status field should show some sort
of a animated gif showing that the file is being uploaded. When the
upload is complete the animated gif is hidden and the new file's
status field does the same thing.

Since we know the name of the file on the server-side, my thinking was
that it wouldn't be hard to associate the correct status column/row
and unhide/hide the animated gif.

That brought me to a new challenge.

Since the entire grid is JS-rendered HTML, how do I search for where
in the grid the file name exists to get the correct status row/column?
I need to be able to access objects from the server to do this. Hence,
my post.

Assuming that the JS-rendered grid isn't going away, how would you
suggest that I go about this?

Thanks for your help.
 
B

bruce barker

first, the browser will only postback <input>, <select> and
<textareas>'s to the server. you can look this values up in the form
collection by name.

if your javascript grid is just tables, and text, the server will see
nothing. the animated gif should be done in javascript.

if you want to status as files are uploaded, then you need to do the
post in an iframe, and write a handler to return status. the ajax
toolkit has this bundled up. jquery also has several versions.

you should get a javascript book, and start learning as you will to know
it.

-- bruce (sqlwork.com)
 
P

pbd22

first, the browser will only postback <input>, <select> and
<textareas>'s to the server. you can look this values up in the form
collection by name.

if your javascript grid is just tables, and text, the server will see
nothing. the animated gif should be done in javascript.

if you want to status as files are uploaded, then you need to do the
post in an iframe, and write a handler to return status. the ajax
toolkit has this bundled up. jquery also has several versions.

you should get a javascript book, and start learning as you will to know
  it.

-- bruce (sqlwork.com)

OK, thanks. Is there any reason why submitting the form to handle the
file upload on the server while firing a javascript event the starts
to poll for status via IFrame is a bad design idea?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top