C#.Net equivalient to Evaluate

View: New views
7 Messages — Rating Filter:   Alert me  

C#.Net equivalient to Evaluate

by Boudreau, Duane :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Is there a C# version of Evaluate?

 

I have multiple controls I'm placing on a form using a query. At post
back I need to retrieve the values. Using Request["field" + x] won't
work for me in this case.

 

TIA,

Duane Boudreau,

Systems Specialist/SQL Administrator

City of Nashua, New Hampshire

229 Main Street, PO Box 2019

Nashua, NH 03061-2019

603 589 3314

 



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble
Ticket application

http://www.houseoffusion.com/banners/view.cfm?bannerid=48

Message: http://www.houseoffusion.com/lists.cfm/link=i:44:1668
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/44
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:44
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.44
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

RE: C#.Net equivalient to Evaluate

by Charlie Arehart :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'd say that, just as in CF, you don't need evaluate as often as you think.
Here's an example that I think demonstrates what you're thinking:

<%@ Page language="c#" %>
<%
        string x="Name";
        Response.Write(Request["field" + x]);
%>

If I call that as filename.aspx?fieldName=bob, the output is bob. Is that
the kind of abstraction you're looking for (though I realize you're probably
using form fields instead, it shouldn't matter at all.)

Charlie Arehart
CTO, New Atlanta Communications, makers of BlueDragon
(678) 256-5395 charlie@...
www.newatlanta.com/bluedragon/

 

> -----Original Message-----
> From: Boudreau, Duane [mailto:BoudreauD@...]
> Sent: Thursday, June 09, 2005 4:30 PM
> To: Net-Talk
> Subject: C#.Net equivalient to Evaluate
>
> Is there a C# version of Evaluate?
>
>  
>
> I have multiple controls I'm placing on a form using a query.
> At post back I need to retrieve the values. Using
> Request["field" + x] won't work for me in this case.
>
>  
>
> TIA,
>
> Duane Boudreau,
>
> Systems Specialist/SQL Administrator
>
> City of Nashua, New Hampshire
>
> 229 Main Street, PO Box 2019
>
> Nashua, NH 03061-2019
>
> 603 589 3314
>
>  
>
>
>
>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Find out how CFTicket can increase your company's customer support
efficiency by 100%
http://www.houseoffusion.com/banners/view.cfm?bannerid=49

Message: http://www.houseoffusion.com/lists.cfm/link=i:44:1669
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/44
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:44
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.44
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

RE: C#.Net equivalent to Evaluate

by Duane Boudreau :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I this case I can not use Request - at least easily. The full client side
name gets changed to something like __ctr00content_pnlAdd_txtFieldName (I
don't have the code in front me at the moment) because it is embedded within
a couple of other page controls.

It would be much easier if I could just get to the variable using its server
side ID, as I do not want to hard code the full name of the variable in the
code.

Duane




-----Original Message-----
From: Charlie Arehart [mailto:charlie@...]
Sent: Thursday, June 09, 2005 4:58 PM
To: Net-Talk
Subject: RE: C#.Net equivalient to Evaluate

I'd say that, just as in CF, you don't need evaluate as often as you think.
Here's an example that I think demonstrates what you're thinking:

<%@ Page language="c#" %>
<%
        string x="Name";
        Response.Write(Request["field" + x]);
%>

If I call that as filename.aspx?fieldName=bob, the output is bob. Is that
the kind of abstraction you're looking for (though I realize you're probably
using form fields instead, it shouldn't matter at all.)

Charlie Arehart
CTO, New Atlanta Communications, makers of BlueDragon
(678) 256-5395 charlie@...
www.newatlanta.com/bluedragon/

 

> -----Original Message-----
> From: Boudreau, Duane [mailto:BoudreauD@...]
> Sent: Thursday, June 09, 2005 4:30 PM
> To: Net-Talk
> Subject: C#.Net equivalient to Evaluate
>
> Is there a C# version of Evaluate?
>
>  
>
> I have multiple controls I'm placing on a form using a query.
> At post back I need to retrieve the values. Using
> Request["field" + x] won't work for me in this case.
>
>  
>
> TIA,
>
> Duane Boudreau,
>
> Systems Specialist/SQL Administrator
>
> City of Nashua, New Hampshire
>
> 229 Main Street, PO Box 2019
>
> Nashua, NH 03061-2019
>
> 603 589 3314
>
>  
>
>
>
>



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Find out how CFTicket can increase your company's customer support
efficiency by 100%
http://www.houseoffusion.com/banners/view.cfm?bannerid=49

Message: http://www.houseoffusion.com/lists.cfm/link=i:44:1670
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/44
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:44
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.44
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

RE: C#.Net equivalent to Evaluate

by Charlie Arehart :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Oh, I'm sorry. When you said "Using Request["field" + x] won't work for me
in this case," I misunderstood. I thought you were implying you hadn't tried
it or that it wasn't working at all.

So it sounds like the dilemma is that you want to determine the form fields
that MS generates as a result of using Server controls, and then refer to
those as passed in. Is that right? In CFML, we'd use form.fieldnames. I
don't know if there's an exact equivalent, and I haven't poked around but
they have to be there as part of the request somehow. Perhaps there's a
method in the httprequest object.

Or someone else will have an answer. Good luck.

Charlie Arehart
CTO, New Atlanta Communications, makers of BlueDragon
(678) 256-5395 charlie@...
www.newatlanta.com/bluedragon/

 

> -----Original Message-----
> From: Duane Boudreau [mailto:duane@...]
> Sent: Thursday, June 09, 2005 6:15 PM
> To: Net-Talk
> Subject: RE: C#.Net equivalent to Evaluate
>
> I this case I can not use Request - at least easily. The full
> client side name gets changed to something like
> __ctr00content_pnlAdd_txtFieldName (I don't have the code in
> front me at the moment) because it is embedded within a
> couple of other page controls.
>
> It would be much easier if I could just get to the variable
> using its server side ID, as I do not want to hard code the
> full name of the variable in the code.
>
> Duane


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble
Ticket application

http://www.houseoffusion.com/banners/view.cfm?bannerid=48

Message: http://www.houseoffusion.com/lists.cfm/link=i:44:1671
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/44
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:44
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.44
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

RE: C#.Net equivalent to Evaluate

by Duane Boudreau :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I am generating the textboxes on the fly by looping thru a query. As I loop
thru the query I give each textbox its own unique ID, "tb_" + ident field
from query. In .Net after the PostBack has occurred I can retrieve the value
of a form field using its server side name instead of its client side name.
In this case the server and client side have very different names.

I just cant figure out how to build the server side name on the fly.

There is an array of controls that is available, Page.Controls, but it only
has one constructer (that I know of) and it takes an int. If I could do
Page.Controls["tb_" + ident field].Text, I'd be golden.

I'm sure there a simple answer to this - I just can't find it anywhere.

Thanks,
Duane



-----Original Message-----
From: Charlie Arehart [mailto:charlie@...]
Sent: Thursday, June 09, 2005 8:28 PM
To: Net-Talk
Subject: RE: C#.Net equivalent to Evaluate

Oh, I'm sorry. When you said "Using Request["field" + x] won't work for me
in this case," I misunderstood. I thought you were implying you hadn't tried
it or that it wasn't working at all.

So it sounds like the dilemma is that you want to determine the form fields
that MS generates as a result of using Server controls, and then refer to
those as passed in. Is that right? In CFML, we'd use form.fieldnames. I
don't know if there's an exact equivalent, and I haven't poked around but
they have to be there as part of the request somehow. Perhaps there's a
method in the httprequest object.

Or someone else will have an answer. Good luck.

Charlie Arehart
CTO, New Atlanta Communications, makers of BlueDragon
(678) 256-5395 charlie@...
www.newatlanta.com/bluedragon/

 

> -----Original Message-----
> From: Duane Boudreau [mailto:duane@...]
> Sent: Thursday, June 09, 2005 6:15 PM
> To: Net-Talk
> Subject: RE: C#.Net equivalent to Evaluate
>
> I this case I can not use Request - at least easily. The full
> client side name gets changed to something like
> __ctr00content_pnlAdd_txtFieldName (I don't have the code in
> front me at the moment) because it is embedded within a
> couple of other page controls.
>
> It would be much easier if I could just get to the variable
> using its server side ID, as I do not want to hard code the
> full name of the variable in the code.
>
> Duane




~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Purchase Dreamweaver with Homesite Plus from House of Fusion, a Macromedia Authorized Affiliate and support the CF community.
http://www.houseoffusion.com/banners/view.cfm?bannerid=54

Message: http://www.houseoffusion.com/lists.cfm/link=i:44:1672
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/44
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:44
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.44
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

RE: C#.Net equivalent to Evaluate

by Kwang Suh :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

>There is an array of controls that is available, Page.Controls, but it only
>has one constructer (that I know of) and it takes an int. If I could do
>Page.Controls["tb_" + ident field].Text, I'd be golden.
>
>I'm sure there a simple answer to this - I just can't find it anywhere.

Did you try Page.FindControl()?

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Find out how CFTicket can increase your company's customer support
efficiency by 100%
http://www.houseoffusion.com/banners/view.cfm?bannerid=49

Message: http://www.houseoffusion.com/lists.cfm/link=i:44:1678
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/44
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:44
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.44
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Parent Message unknown RE: C#.Net equivalent to Evaluate

by Boudreau, Duane :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I ended up doing something similar. The dynamic controls are all
embedded inside a table which has a static id. So I used
tblPM.Parent.FindControl("ctrl" + index.ToString());

-----Original Message-----
From: Kwang Suh [mailto:ksuh@...]
Sent: Tuesday, June 14, 2005 11:55 AM
To: Net-Talk
Subject: RE: C#.Net equivalent to Evaluate

>There is an array of controls that is available, Page.Controls, but it
only
>has one constructer (that I know of) and it takes an int. If I could do
>Page.Controls["tb_" + ident field].Text, I'd be golden.
>
>I'm sure there a simple answer to this - I just can't find it anywhere.

Did you try Page.FindControl()?



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Find out how CFTicket can increase your company's customer support
efficiency by 100%
http://www.houseoffusion.com/banners/view.cfm?bannerid=49

Message: http://www.houseoffusion.com/lists.cfm/link=i:44:1680
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/44
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:44
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.44
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54