944,198 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Unsolved
  • Views: 10041
  • ASP.NET RSS
You are currently viewing page 1 of this multi-page discussion thread
Jun 19th, 2006
0

variables from javascript in asp.net

Expand Post »
i need to use the variables declared in javascript in asp.net
saw a thread suggesting hidden textfields
but that wud help in request or query strings
what if i needed to use the value of a variable declared in javascript by fulfilling some condition into an INSERT COMMAND.
the page will not be posted back
n the client side script sets the value for the variable
how do i incorporate the value in asp.net
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
adnan1888 is offline Offline
6 posts
since Jun 2006
Jun 19th, 2006
0

Re: variables from javascript in asp.net

i'm confused about what you are trying to do. if nothing is going to go back to your server, then how are you going to use the asp.net code?
Reputation Points: 14
Solved Threads: 19
Posting Pro in Training
campkev is offline Offline
484 posts
since Jul 2005
Jun 20th, 2006
0

Re: variables from javascript in asp.net

i want to use the variable values declared in javascript in the asp code render blocks
Reputation Points: 10
Solved Threads: 0
Newbie Poster
adnan1888 is offline Offline
6 posts
since Jun 2006
Jun 20th, 2006
0

Re: variables from javascript in asp.net

Step 1: the asp code is handled by the server before the page is returned to the client.

Step 2: the javascript is handled by the clients browser after the page is returned to it

Step 3:the javascript can then affect whatever (which boxes are checked, the value of fields, etc) which can then be sent back to the server, either as a post back or posting to a new page.

which step are you trying to manipulate?
Reputation Points: 14
Solved Threads: 19
Posting Pro in Training
campkev is offline Offline
484 posts
since Jul 2005
Jun 21st, 2006
0

Re: variables from javascript in asp.net

Quote originally posted by campkev ...
Step 1: the asp code is handled by the server before the page is returned to the client.

Step 2: the javascript is handled by the clients browser after the page is returned to it

Step 3:the javascript can then affect whatever (which boxes are checked, the value of fields, etc) which can then be sent back to the server, either as a post back or posting to a new page.

which step are you trying to manipulate?


thanx for the quick reply
my prob is that ....say suppose we do not want to affect any field
just declare a value which is to be posted
we can assign the value to a hidden text box....but any other way???
Reputation Points: 10
Solved Threads: 0
Newbie Poster
adnan1888 is offline Offline
6 posts
since Jun 2006
Jun 21st, 2006
0

Re: variables from javascript in asp.net

that is pretty much the standard way to do it, why are you looking for another way. of course, you need to be careful if you are taking text and putting it directly into a sql statement
Reputation Points: 14
Solved Threads: 19
Posting Pro in Training
campkev is offline Offline
484 posts
since Jul 2005
Jun 21st, 2006
1

Re: variables from javascript in asp.net

A web browser, regardless of which, can only communicate to a web server via an HTTP REQUEST, which come in two flavors: POST, and GET.

POST = A form.
GET = A querystring.

That's all.

A server-side language, such as ASP.NET or any other, can only generate a RESPONSE. That response can be any document for which there is a corresponding MIME type. If HTML, you can place HTML, CSS, and JavaScript in the response.

Despite all the fancy bells and whistles in ASP.NET, all it does is generate RESPONSE objects. It can do all sorts of fancy stuff along the way, but that's the final result.

There are a couple of different mechanisms for shuttling values between the client and server.

One of them is the ViewState, which on the client side is a big nasty encoded hidden input element, but on the server-side becomes an "object" with methods and properties.

The other is to use ASP.NET to create client-side scripts and place them in the RESPONSE.
Last edited by tgreer; Jun 21st, 2006 at 5:21 pm.
Team Colleague
Reputation Points: 227
Solved Threads: 37
Made Her Cry
tgreer is offline Offline
1,697 posts
since Dec 2004
Jun 21st, 2006
0

Re: variables from javascript in asp.net

that's what I was trying to get across, although not very well I think. and with him saying this is not going to post back, I am assuming that it is going to post/get to new page. If this is the case, I do believe that viewstate is out.
Reputation Points: 14
Solved Threads: 19
Posting Pro in Training
campkev is offline Offline
484 posts
since Jul 2005
Jun 21st, 2006
0

Re: variables from javascript in asp.net

It's not going to post back? Yeah, that's a loaded term. He could be saying that he's testing for "IsPostBack" on Page_Load, and not seeing the value there. If that's the case:

Of course you wouldn't. Only server-controls have their values from the Form stored with them. If you're using an HTML hidden element, or a QueryString key-value pair, you need to find it's value in the REQUEST object.

Or, he could be saying he isn't going to "post" the value "back" to the server application... in which case, this isn't an ASP.NET question, it's a JavaScript/HTML question.

adnan: sorry, but you need to ask extremely clear questions. I know we probably have a language barrier, but keep trying. We all want to help. Can you share some of your code with us? Perhaps that would help.
Last edited by tgreer; Jun 21st, 2006 at 5:48 pm.
Team Colleague
Reputation Points: 227
Solved Threads: 37
Made Her Cry
tgreer is offline Offline
1,697 posts
since Dec 2004
Jun 22nd, 2006
0

Re: variables from javascript in asp.net

thanks every one for the quick n prompt replies

i guess wud help a lot if i post my code.....

but right now i got over with my problem

one thing i want to assure u is that if i am not clear in my question ....it is because i am a newbie to programming....not because of a language barrier

thanx everyone once again

next time i have a problem i know where to post it
Reputation Points: 10
Solved Threads: 0
Newbie Poster
adnan1888 is offline Offline
6 posts
since Jun 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: Date and Time
Next Thread in ASP.NET Forum Timeline: Where is the table ????





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC