Hello,
I'm using javascript's insertAdjacentHtml() to insert images to the
webform at runtime. This runs fine(image successfully displayed at the
browser) but when I tried to access the control's src using FindControl()
function in the code-behind, it seems that the control doesn't even exist.
I know that I can add controls on the server-side, but then a postback
will be needed which is the thing I want to avoid. Does anyone have idea on
how to do so? Thanks a lot.
--
If you want to mail to me, please replace all instance of "e" to "a" in my
email address. Thank you.
Sorry for any inconvience caused, but there's many spam-mailers. 7 6954
How can server know what you are doing on client side? If you want server to
be aware of controls, you must make them server ones. What is the purpose of
adding controls? May be you can prepare everything on server side and then
just hide/show them on client?
Eliyahu
"Lau Lei Cheong" <le****@yehoo.com.hk> wrote in message
news:OR**************@TK2MSFTNGP10.phx.gbl... Hello,
I'm using javascript's insertAdjacentHtml() to insert images to the webform at runtime. This runs fine(image successfully displayed at the browser) but when I tried to access the control's src using FindControl() function in the code-behind, it seems that the control doesn't even exist.
I know that I can add controls on the server-side, but then a postback will be needed which is the thing I want to avoid. Does anyone have idea
on how to do so? Thanks a lot.
-- If you want to mail to me, please replace all instance of "e" to "a" in my email address. Thank you. Sorry for any inconvience caused, but there's many spam-mailers.
Hereis how I think about this:
In theory, any htmlcontrol with runat="server" tag within a server-side form
will be posted back to server on the "post" action. So I think by inserting
things such as "<input id=\"txtctrl_1\" type=\"text\" runat=\"server\"
value=\"\something">" the control id and it's value will eventally be posted
back to server on a post event within the request stream.
And from my understanding, Page.FindControl() is simple searching the
returned stream for the specified key and return the result(So that I can
still access the controls created dynamically on the server-side using
Form.Controls.Add()). Therefore, there's no reason I can think of that will
prevent me to access the controls created by the method stated in the
beginning.
For the second question, the answer is no. The webform will allow users to
add as many pictures(and/or texts) as they wish on it and there is no way I
can predict how much picture a user may enter. (even set a value as high as
100 may be insufficient)
"Eliyahu Goldin" <re*************@monarchmed.com> ¦b¶l¥ó
news:eY**************@TK2MSFTNGP10.phx.gbl ¤¤¼¶¼g... How can server know what you are doing on client side? If you want server
to be aware of controls, you must make them server ones. What is the purpose
of adding controls? May be you can prepare everything on server side and then just hide/show them on client?
Eliyahu
"Lau Lei Cheong" <le****@yehoo.com.hk> wrote in message news:OR**************@TK2MSFTNGP10.phx.gbl... Hello,
I'm using javascript's insertAdjacentHtml() to insert images to the webform at runtime. This runs fine(image successfully displayed at the browser) but when I tried to access the control's src using
FindControl() function in the code-behind, it seems that the control doesn't even
exist. I know that I can add controls on the server-side, but then a
postback will be needed which is the thing I want to avoid. Does anyone have idea on how to do so? Thanks a lot.
-- If you want to mail to me, please replace all instance of "e" to "a" in
my email address. Thank you. Sorry for any inconvience caused, but there's many spam-mailers.
ASP.NET controls are abstractions of various user interface elements such as
text fields and drop down lists. The controls on a page are held in the
Form.Controls collection. When ASP.NET renders a page it iterates this
collection and renders every single control as HTML code. The controls are
rendered as HTML elements such as INPUT and SELECT contained with in a HTML
FORM element. When the rendering process is complete the HTML code is
returned to the browser as an HTTP response.
The browser then parses the HTML code and adds the various elements to it's
document object model (DOM) making it possible to use script add, remove or
change HTML elements in the browser.
When a post back is performed the FORM containing is submitted to the
server. The entire DOM is not sent to the server, only the values and
identifiers of the INPUT and SELECT elements are included in the HTTP POST
request.
When you add a new HTML element to the page via script you're only adding it
to the DOM. You can add a runat attribute to any DOM element, but this
attribute is not recognised by the browser and has no function in practice.
If you want to upload the pictures to the server you will have to use a
INPUT type="file" HTML element to include the actual image in the HTTP
request. Just adding the HTML code dynamically won't cut it.
Anders Norås http://dotnetjunkies.com/weblog/anoras/
Well, you have to correct your understanding. runat=server has no effect on
client. It's a server-side tag. Client doesn't know what it means and just
ignores it.
As to the second question, if you wish to pass images to server, I don't
think you can get much more than standard file uploading one-by-one.
Alternatively you can use/make a special ActiveX control.
Eliyahu
"Lau Lei Cheong" <le****@yehoo.com.hk> wrote in message
news:OU**************@tk2msftngp13.phx.gbl... Hereis how I think about this: In theory, any htmlcontrol with runat="server" tag within a server-side
form will be posted back to server on the "post" action. So I think by
inserting things such as "<input id=\"txtctrl_1\" type=\"text\" runat=\"server\" value=\"\something">" the control id and it's value will eventally be
posted back to server on a post event within the request stream. And from my understanding, Page.FindControl() is simple searching the returned stream for the specified key and return the result(So that I can still access the controls created dynamically on the server-side using Form.Controls.Add()). Therefore, there's no reason I can think of that
will prevent me to access the controls created by the method stated in the beginning.
For the second question, the answer is no. The webform will allow users to add as many pictures(and/or texts) as they wish on it and there is no way
I can predict how much picture a user may enter. (even set a value as high
as 100 may be insufficient)
"Eliyahu Goldin" <re*************@monarchmed.com> ¦b¶l¥ó news:eY**************@TK2MSFTNGP10.phx.gbl ¤¤¼¶¼g... How can server know what you are doing on client side? If you want
server to be aware of controls, you must make them server ones. What is the
purpose of adding controls? May be you can prepare everything on server side and
then just hide/show them on client?
Eliyahu
"Lau Lei Cheong" <le****@yehoo.com.hk> wrote in message news:OR**************@TK2MSFTNGP10.phx.gbl... Hello,
I'm using javascript's insertAdjacentHtml() to insert images to
the webform at runtime. This runs fine(image successfully displayed at the browser) but when I tried to access the control's src using FindControl() function in the code-behind, it seems that the control doesn't even exist. I know that I can add controls on the server-side, but then a postback will be needed which is the thing I want to avoid. Does anyone have
idea on how to do so? Thanks a lot.
-- If you want to mail to me, please replace all instance of "e" to "a"
in my email address. Thank you. Sorry for any inconvience caused, but there's many spam-mailers.
Yes, of course, I've created another form with <input type="file"> to upload
the images, that's why I could simply add an image element to it to show it.
Taking yours and Eliyahu's advice I've created <input type="hidden"> fields
that holds various properties of the controls yet they seem do not return in
the request stream. Any ideas?
"Anders Norås [MCAD]" <an**********@objectware.no> ¦b¶l¥ó
news:Ok**************@TK2MSFTNGP11.phx.gbl ¤¤¼¶¼g... ASP.NET controls are abstractions of various user interface elements such
as text fields and drop down lists. The controls on a page are held in the Form.Controls collection. When ASP.NET renders a page it iterates this collection and renders every single control as HTML code. The controls are rendered as HTML elements such as INPUT and SELECT contained with in a
HTML FORM element. When the rendering process is complete the HTML code is returned to the browser as an HTTP response. The browser then parses the HTML code and adds the various elements to
it's document object model (DOM) making it possible to use script add, remove
or change HTML elements in the browser. When a post back is performed the FORM containing is submitted to the server. The entire DOM is not sent to the server, only the values and identifiers of the INPUT and SELECT elements are included in the HTTP POST request.
When you add a new HTML element to the page via script you're only adding
it to the DOM. You can add a runat attribute to any DOM element, but this attribute is not recognised by the browser and has no function in
practice. If you want to upload the pictures to the server you will have to use a INPUT type="file" HTML element to include the actual image in the HTTP request. Just adding the HTML code dynamically won't cut it.
Anders Norås http://dotnetjunkies.com/weblog/anoras/
Do your <input type="hidden"> have runat=server?
Eliyahu
"Lau Lei Cheong" <le****@yehoo.com.hk> wrote in message
news:On**************@TK2MSFTNGP14.phx.gbl... Yes, of course, I've created another form with <input type="file"> to
upload the images, that's why I could simply add an image element to it to show
it. Taking yours and Eliyahu's advice I've created <input type="hidden">
fields that holds various properties of the controls yet they seem do not return
in the request stream. Any ideas?
"Anders Norås [MCAD]" <an**********@objectware.no> ¦b¶l¥ó news:Ok**************@TK2MSFTNGP11.phx.gbl ¤¤¼¶¼g... ASP.NET controls are abstractions of various user interface elements
such as text fields and drop down lists. The controls on a page are held in the Form.Controls collection. When ASP.NET renders a page it iterates this collection and renders every single control as HTML code. The controls
are rendered as HTML elements such as INPUT and SELECT contained with in a HTML FORM element. When the rendering process is complete the HTML code is returned to the browser as an HTTP response. The browser then parses the HTML code and adds the various elements to it's document object model (DOM) making it possible to use script add, remove or change HTML elements in the browser. When a post back is performed the FORM containing is submitted to the server. The entire DOM is not sent to the server, only the values and identifiers of the INPUT and SELECT elements are included in the HTTP
POST request.
When you add a new HTML element to the page via script you're only
adding it to the DOM. You can add a runat attribute to any DOM element, but this attribute is not recognised by the browser and has no function in practice. If you want to upload the pictures to the server you will have to use a INPUT type="file" HTML element to include the actual image in the HTTP request. Just adding the HTML code dynamically won't cut it.
Anders Norås http://dotnetjunkies.com/weblog/anoras/
Yes. But seems all "client-side added" hidden boxes cannot add themselves in
the request stream. (Also examinated request stream to confirm that)
As time is running out I'll settle this by adding a hidden box at design
time, and serialize the image/layers' values using javascript just before a
postback to server.
I'd be appreciated if someone can solve it, as the additional javascript
makes my code grow very large. And is likely to get problem when the
serialized data size exceeds the hidden box's size limit.
"Eliyahu Goldin" <re*************@monarchmed.com> ¦b¶l¥ó
news:em**************@TK2MSFTNGP09.phx.gbl ¤¤¼¶¼g... Do your <input type="hidden"> have runat=server?
Eliyahu
"Lau Lei Cheong" <le****@yehoo.com.hk> wrote in message news:On**************@TK2MSFTNGP14.phx.gbl... Yes, of course, I've created another form with <input type="file"> to upload the images, that's why I could simply add an image element to it to show it. Taking yours and Eliyahu's advice I've created <input type="hidden">
fields that holds various properties of the controls yet they seem do not
return in the request stream. Any ideas?
"Anders Norås [MCAD]" <an**********@objectware.no> ¦b¶l¥ó news:Ok**************@TK2MSFTNGP11.phx.gbl ¤¤¼¶¼g... ASP.NET controls are abstractions of various user interface elements such as text fields and drop down lists. The controls on a page are held in
the Form.Controls collection. When ASP.NET renders a page it iterates this collection and renders every single control as HTML code. The controls are rendered as HTML elements such as INPUT and SELECT contained with in a HTML FORM element. When the rendering process is complete the HTML code is returned to the browser as an HTTP response. The browser then parses the HTML code and adds the various elements to it's document object model (DOM) making it possible to use script add,
remove or change HTML elements in the browser. When a post back is performed the FORM containing is submitted to the server. The entire DOM is not sent to the server, only the values and identifiers of the INPUT and SELECT elements are included in the HTTP POST request.
When you add a new HTML element to the page via script you're only adding it to the DOM. You can add a runat attribute to any DOM element, but this attribute is not recognised by the browser and has no function in practice. If you want to upload the pictures to the server you will have to use
a INPUT type="file" HTML element to include the actual image in the HTTP request. Just adding the HTML code dynamically won't cut it.
Anders Norås http://dotnetjunkies.com/weblog/anoras/
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: James G. Beldock |
last post by:
I have seen the following behavior: when issuing a Page.FindControl() for a
control which exists in an item template (from within an ItemDataBound()
event, for example), I get nulls back...
|
by: Kevin Phifer |
last post by:
Ok, before anyone freaks out, I have a solution I need to
create that gathers content from maybe different places.
Each one can return a <form> in the html, so its the
classic can't have more than...
|
by: Adam Billmeier |
last post by:
Problem:
I am trying to use FindControl to grab a dropdownlist that is in the
EditItemTemplate of a Datalist and then Bind it to a dataset. I also then
need to put the correct values in all of...
|
by: tma |
last post by:
My code below returns the .text property of the chkEqmtRental check box but
not it's checked state. I'm creating the control in a placeholder and need
to access the check box in the codebehind....
|
by: Kezza |
last post by:
Hi There..
I have dynamically created some textbox and checkbox controls by adding them
to a panel. Now I would like to get the values out.
I have created a
for each loop that I can see the...
|
by: Hexman |
last post by:
Hello All,
I'd like your comments on the code below. The sub does exactly what I want it to do but I don't feel that it is solid as all. It seems like I'm
using some VB6 code, .Net2003 code,...
|
by: kcddoorman |
last post by:
I have searched all over the internets for a solution to this problem and there are many ways to work around it but I'm wondering if there is a more simple solution.
I have asp.net 2.0 working with...
|
by: |
last post by:
I dynamically create controls (textboxes) in a repeater control. I know
their names (eg. TextBox1). How do I find the text of TextBox1 in the Form?
FindControl does not seem to work.
|
by: ptcoder |
last post by:
Hello everyone.
I have done a lot of reading regarding the recursive issue with FindControl. I have a FormView with an <EditItemTemplate> and all I want to do is add javascript attributes to the...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |