473,378 Members | 1,607 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

How can I get the value from the client-side created element object?

Hi:

I created a web-form user control. And in client-site, there is a link which
will create a Input element object when it is clicked.

<script language=javascript>

.......
var nameInput = document.createElement("input");
nameInput.setAttribute("id", "authorname");
......

</script>

But when click "save" button" on this page, I can not get the value of the
created element object in the user control by (in C#)

.......
string x=Request["authorname"];
.......

So how can I get the value from the client-side created element in a user
control of ASP.NET?

Thanks

Q.


Nov 18 '05 #1
7 1630
not sure if this wold help, but you might want to add:
runat="server"
when creating the object

"Quentin Huo" <q.***@manyworlds.com> wrote in message
news:eT*************@TK2MSFTNGP10.phx.gbl...
Hi:

I created a web-form user control. And in client-site, there is a link which will create a Input element object when it is clicked.

<script language=javascript>

......
var nameInput = document.createElement("input");
nameInput.setAttribute("id", "authorname");
.....

</script>

But when click "save" button" on this page, I can not get the value of the created element object in the user control by (in C#)

......
string x=Request["authorname"];
......

So how can I get the value from the client-side created element in a user
control of ASP.NET?

Thanks

Q.

Nov 18 '05 #2
No, this won't help on the client side. "runat" is an instruction for
ASP.NET. There is no ASP.NET on the client side.

There are several way how to transmit values from client to server. You can
use <input type=hidden> element, or you can add a parameter to the query
string, not limited to these 2 only.

Eliyahu

"Filip" <fi******@hotmail.com> wrote in message
news:ep**************@TK2MSFTNGP12.phx.gbl...
not sure if this wold help, but you might want to add:
runat="server"
when creating the object

"Quentin Huo" <q.***@manyworlds.com> wrote in message
news:eT*************@TK2MSFTNGP10.phx.gbl...
Hi:

I created a web-form user control. And in client-site, there is a link

which
will create a Input element object when it is clicked.

<script language=javascript>

......
var nameInput = document.createElement("input");
nameInput.setAttribute("id", "authorname");
.....

</script>

But when click "save" button" on this page, I can not get the value of

the
created element object in the user control by (in C#)

......
string x=Request["authorname"];
......

So how can I get the value from the client-side created element in a user control of ASP.NET?

Thanks

Q.


Nov 18 '05 #3
Hi

This should work

Client
var e = document.createElement("INPUT");
e.name = "theNAME"; // Name of element
document.forms["FORMNAME"].appendChild(e);

Server
string sRes = (Request.Form["theNAME"] != null ) ?
Request.Form["theNAME"].ToString() : "";

--
Best Regards
Vidar Petursson
==============================
Microsoft Scripting MVP
http://www.microsoft.com/technet/scriptcenter
==============================
"Quentin Huo" <q.***@manyworlds.com> wrote in message
news:eT*************@TK2MSFTNGP10.phx.gbl...
Hi:

I created a web-form user control. And in client-site, there is a link
which
will create a Input element object when it is clicked.

<script language=javascript>

......
var nameInput = document.createElement("input");
nameInput.setAttribute("id", "authorname");
.....

</script>

But when click "save" button" on this page, I can not get the value of
the
created element object in the user control by (in C#)

......
string x=Request["authorname"];
......

So how can I get the value from the client-side created element in a user
control of ASP.NET?

Thanks

Q.

Nov 18 '05 #4
Hi:

Unfortuately, it doesn't work. But anyway, thanks for you guys.

So I am thinking another way to handle this: how can I create elements
dynamically in server-side?

I am trying to create a page for edit books' information. Some books have
one author and some books have more than one authors. So, I want to give
only one text box for the author name. And I will create a link saying "more
authors". When a book has two authors, click the "more authors" link and a
new text box will be created in the server-side.

I know I should create a method in the code-behind to handle the click event
for that link. But I want to know how to create an element ( such as input
box) in the server-side?

I tried to create a asp:label named "newAuthors" (ID) in the page, and I
create the new text box as:

.......

newAuthors.Text = "<input runat=server id=newAuthors name=newAuthors >";

.......

but if I put a name in this box and post the page, the name that I input
cannot be shown in the box anymore (I think it is not in the VIEWSTATE). So
I think there should be another better way to create an element in ASP.NET.

Any better way?

Thank you very much!

Q.


"Vidar Petursson" <th**************************@icysoft.com> wrote in
message news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi

This should work

Client
var e = document.createElement("INPUT");
e.name = "theNAME"; // Name of element
document.forms["FORMNAME"].appendChild(e);

Server
string sRes = (Request.Form["theNAME"] != null ) ?
Request.Form["theNAME"].ToString() : "";

--
Best Regards
Vidar Petursson
==============================
Microsoft Scripting MVP
http://www.microsoft.com/technet/scriptcenter
==============================
"Quentin Huo" <q.***@manyworlds.com> wrote in message
news:eT*************@TK2MSFTNGP10.phx.gbl...
Hi:

I created a web-form user control. And in client-site, there is a link
which
will create a Input element object when it is clicked.

<script language=javascript>

......
var nameInput = document.createElement("input");
nameInput.setAttribute("id", "authorname");
.....

</script>

But when click "save" button" on this page, I can not get the value of
the
created element object in the user control by (in C#)

......
string x=Request["authorname"];
......

So how can I get the value from the client-side created element in a user control of ASP.NET?

Thanks

Q.


Nov 18 '05 #5
Hi

Hmmm just tested it here and it worked perfectly, no problem getting
the data in input....

--
Best Regards
Vidar Petursson
==============================
Microsoft Visual: Scripting MVP 2000-2004
http://www.icysoft.com/
http://www.deus-x.com/ Instant e-commerce
http://www.microsoft.com/technet/scriptcenter/
Playground: http://213.190.104.211/ ( IE 5.5+ only )

No matter where you go there you are
==============================
"Quentin Huo" <q.***@manyworlds.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi:

Unfortuately, it doesn't work. But anyway, thanks for you guys.

So I am thinking another way to handle this: how can I create elements
dynamically in server-side?

I am trying to create a page for edit books' information. Some books have
one author and some books have more than one authors. So, I want to give
only one text box for the author name. And I will create a link saying
"more
authors". When a book has two authors, click the "more authors" link and a
new text box will be created in the server-side.

I know I should create a method in the code-behind to handle the click
event
for that link. But I want to know how to create an element ( such as input
box) in the server-side?

I tried to create a asp:label named "newAuthors" (ID) in the page, and I
create the new text box as:

......

newAuthors.Text = "<input runat=server id=newAuthors name=newAuthors >";

......

but if I put a name in this box and post the page, the name that I input
cannot be shown in the box anymore (I think it is not in the VIEWSTATE).
So
I think there should be another better way to create an element in
ASP.NET.

Any better way?

Thank you very much!

Q.


"Vidar Petursson" <th**************************@icysoft.com> wrote in
message news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi

This should work

Client
var e = document.createElement("INPUT");
e.name = "theNAME"; // Name of element
document.forms["FORMNAME"].appendChild(e);

Server
string sRes = (Request.Form["theNAME"] != null ) ?
Request.Form["theNAME"].ToString() : "";

--
Best Regards
Vidar Petursson
==============================
Microsoft Scripting MVP
http://www.microsoft.com/technet/scriptcenter
==============================
"Quentin Huo" <q.***@manyworlds.com> wrote in message
news:eT*************@TK2MSFTNGP10.phx.gbl...
> Hi:
>
> I created a web-form user control. And in client-site, there is a link
> which
> will create a Input element object when it is clicked.
>
> <script language=javascript>
>
> ......
> var nameInput = document.createElement("input");
> nameInput.setAttribute("id", "authorname");
> .....
>
> </script>
>
> But when click "save" button" on this page, I can not get the value of
> the
> created element object in the user control by (in C#)
>
> ......
> string x=Request["authorname"];
> ......
>
> So how can I get the value from the client-side created element in a user > control of ASP.NET?
>
> Thanks
>
> Q.
>
>
>
>



Nov 18 '05 #6
Check :
- you have a name attribute
- it is inside the client side form tag
- it is enabled (likely by default)

Else it is not posted to the server

Patrice

"Quentin Huo" <q.***@manyworlds.com> a écrit dans le message de
news:eT*************@TK2MSFTNGP10.phx.gbl...
Hi:

I created a web-form user control. And in client-site, there is a link which will create a Input element object when it is clicked.

<script language=javascript>

......
var nameInput = document.createElement("input");
nameInput.setAttribute("id", "authorname");
.....

</script>

But when click "save" button" on this page, I can not get the value of the created element object in the user control by (in C#)

......
string x=Request["authorname"];
......

So how can I get the value from the client-side created element in a user
control of ASP.NET?

Thanks

Q.

Nov 18 '05 #7
It WORKS! (I made a mistake before).

Thanks a lot!

Q.

"Vidar Petursson" <th**************************@icysoft.com> wrote in
message news:us**************@TK2MSFTNGP09.phx.gbl...
Hi

Hmmm just tested it here and it worked perfectly, no problem getting
the data in input....

--
Best Regards
Vidar Petursson
==============================
Microsoft Visual: Scripting MVP 2000-2004
http://www.icysoft.com/
http://www.deus-x.com/ Instant e-commerce
http://www.microsoft.com/technet/scriptcenter/
Playground: http://213.190.104.211/ ( IE 5.5+ only )

No matter where you go there you are
==============================
"Quentin Huo" <q.***@manyworlds.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi:

Unfortuately, it doesn't work. But anyway, thanks for you guys.

So I am thinking another way to handle this: how can I create elements
dynamically in server-side?

I am trying to create a page for edit books' information. Some books have one author and some books have more than one authors. So, I want to give
only one text box for the author name. And I will create a link saying
"more
authors". When a book has two authors, click the "more authors" link and a new text box will be created in the server-side.

I know I should create a method in the code-behind to handle the click
event
for that link. But I want to know how to create an element ( such as input box) in the server-side?

I tried to create a asp:label named "newAuthors" (ID) in the page, and I create the new text box as:

......

newAuthors.Text = "<input runat=server id=newAuthors name=newAuthors >";

......

but if I put a name in this box and post the page, the name that I input
cannot be shown in the box anymore (I think it is not in the VIEWSTATE).
So
I think there should be another better way to create an element in
ASP.NET.

Any better way?

Thank you very much!

Q.


"Vidar Petursson" <th**************************@icysoft.com> wrote in
message news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi

This should work

Client
var e = document.createElement("INPUT");
e.name = "theNAME"; // Name of element
document.forms["FORMNAME"].appendChild(e);

Server
string sRes = (Request.Form["theNAME"] != null ) ?
Request.Form["theNAME"].ToString() : "";

--
Best Regards
Vidar Petursson
==============================
Microsoft Scripting MVP
http://www.microsoft.com/technet/scriptcenter
==============================
"Quentin Huo" <q.***@manyworlds.com> wrote in message
news:eT*************@TK2MSFTNGP10.phx.gbl...
> Hi:
>
> I created a web-form user control. And in client-site, there is a link > which
> will create a Input element object when it is clicked.
>
> <script language=javascript>
>
> ......
> var nameInput = document.createElement("input");
> nameInput.setAttribute("id", "authorname");
> .....
>
> </script>
>
> But when click "save" button" on this page, I can not get the value of > the
> created element object in the user control by (in C#)
>
> ......
> string x=Request["authorname"];
> ......
>
> So how can I get the value from the client-side created element in a

user
> control of ASP.NET?
>
> Thanks
>
> Q.
>
>
>
>



Nov 18 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Simon Wadsworth | last post by:
My application uses VB6 WebClasses to handle the UI, so all requests come in via a stub ASP page. I would like to know the time taken for the request to be processed. I am trying to use the...
6
by: Tom Dacon | last post by:
If you're not putting assemblies in the GAC, but are referencing shared code with copylocal=true into the projects that use them, is there any value to signing the assemblies? In the environment...
0
by: Daniel | last post by:
how to change the value of Request.ServerVariables on the ser ver? if not possible is there some way to change it by sending back javascript to the client and having the client automaticaly do...
1
by: Peter | last post by:
Hi, I have the following scenarios: client/server programs implemented with winsock are installed on all systems inthe network (assume it contains s1, s2, and s3, and other systems). If I send a...
2
by: TadPole | last post by:
Hi all, My main problems are::::::::: 1. Set a value within a block container that can be used and changed by subsequent templates/block-containers/tables etc.. 2. get/determine/find the...
2
by: Curious | last post by:
Hi, I have a similar class to the one shown below, with the main difference that it has more properties. Now I am using the enum to indicate what type of data current exists. I am using...
2
by: Lars Netzel | last post by:
Hi I'm having a DropDown box with 2 items... one with Value 1 and one with Value 2. If I load the page and it has Value 1 selected from page_load() and then select Value 2 on the form.. .and...
1
by: Pieter Coucke | last post by:
Hi, A given column of my Report (reporting services 2005) contains clients or null values. I want the user to be able to chose one or more clients for the parameter, and than show only those...
0
by: Maart_newbie | last post by:
Hi all, I've got a question about returning the value of a pk-column to a DataTable after inserting a row (via a data-adapter) using MySql5. Here is the SQL and code concerned: ...
4
benchpolo
by: benchpolo | last post by:
I have a form that contains client information such as client id, name, address etc. etc. Then I have another form which is a list box that contains the client id and name. What I’m trying to...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
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...
0
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.