By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,635 Members | 1,703 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,635 IT Pros & Developers. It's quick & easy.

How do you inspect HTML controls in compiled C#?

P: n/a
I have a C# application that builds dynamic HTML and renders it. Because it
is rendered in this way, the input controls are not server controls. I write
the entire page, which has a variable number of detail lines for an order. I
want the user to be able to change values on these detail lines and hit an
'update' button. I know how to do this in Javascript, but I'd like to be
able to inspect the controls that come back to my C# program during a
Postback. Since these are not server controls, they are not available in
Page.Controls. What is the 'proper' way to inspect these inside of the
compiled C# program? Right now I'm parsing them out through javascript, and
passing them through cookies, but there has to be a better way than this,
isn't there?
Nov 19 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Hi Brian,

Do you have Visual Studio.Net? If so, three are oodles of ways to inspect
process and data in your app, using BreakPoints, Watches, etc.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Sometimes you eat the elephant.
Sometimes the elephant eats you.

"Brian Kitt" <Br*******@discussions.microsoft.com> wrote in message
news:C5**********************************@microsof t.com...
I have a C# application that builds dynamic HTML and renders it. Because
it
is rendered in this way, the input controls are not server controls. I
write
the entire page, which has a variable number of detail lines for an order.
I
want the user to be able to change values on these detail lines and hit an
'update' button. I know how to do this in Javascript, but I'd like to be
able to inspect the controls that come back to my C# program during a
Postback. Since these are not server controls, they are not available in
Page.Controls. What is the 'proper' way to inspect these inside of the
compiled C# program? Right now I'm parsing them out through javascript,
and
passing them through cookies, but there has to be a better way than this,
isn't there?

Nov 19 '05 #2

P: n/a
Yes, running .NET, but what I meant was I needed to get the value of the
controls in my C# program. Programatically I need to check the value of the
controls. I can't figure out how to do it through any normal object.

"Kevin Spencer" wrote:
Hi Brian,

Do you have Visual Studio.Net? If so, three are oodles of ways to inspect
process and data in your app, using BreakPoints, Watches, etc.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Sometimes you eat the elephant.
Sometimes the elephant eats you.

"Brian Kitt" <Br*******@discussions.microsoft.com> wrote in message
news:C5**********************************@microsof t.com...
I have a C# application that builds dynamic HTML and renders it. Because
it
is rendered in this way, the input controls are not server controls. I
write
the entire page, which has a variable number of detail lines for an order.
I
want the user to be able to change values on these detail lines and hit an
'update' button. I know how to do this in Javascript, but I'd like to be
able to inspect the controls that come back to my C# program during a
Postback. Since these are not server controls, they are not available in
Page.Controls. What is the 'proper' way to inspect these inside of the
compiled C# program? Right now I'm parsing them out through javascript,
and
passing them through cookies, but there has to be a better way than this,
isn't there?


Nov 19 '05 #3

P: n/a
When you say "running .Net," are you referring to the .Net platform, or, as
I asked, Visual Studio.Net?

In any case, the question is moot, since you want to do it programmatically.
Your best bet is to use WebControls or HtmlControls to do this. That is what
they are designed for. Any other solution is going to be problematic.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Sometimes you eat the elephant.
Sometimes the elephant eats you.

"Brian Kitt" <Br*******@discussions.microsoft.com> wrote in message
news:30**********************************@microsof t.com...
Yes, running .NET, but what I meant was I needed to get the value of the
controls in my C# program. Programatically I need to check the value of
the
controls. I can't figure out how to do it through any normal object.

"Kevin Spencer" wrote:
Hi Brian,

Do you have Visual Studio.Net? If so, three are oodles of ways to inspect
process and data in your app, using BreakPoints, Watches, etc.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Sometimes you eat the elephant.
Sometimes the elephant eats you.

"Brian Kitt" <Br*******@discussions.microsoft.com> wrote in message
news:C5**********************************@microsof t.com...
>I have a C# application that builds dynamic HTML and renders it.
>Because
>it
> is rendered in this way, the input controls are not server controls. I
> write
> the entire page, which has a variable number of detail lines for an
> order.
> I
> want the user to be able to change values on these detail lines and hit
> an
> 'update' button. I know how to do this in Javascript, but I'd like to
> be
> able to inspect the controls that come back to my C# program during a
> Postback. Since these are not server controls, they are not available
> in
> Page.Controls. What is the 'proper' way to inspect these inside of the
> compiled C# program? Right now I'm parsing them out through
> javascript,
> and
> passing them through cookies, but there has to be a better way than
> this,
> isn't there?


Nov 19 '05 #4

P: n/a
Maybe I'm approaching this wrong then. My end result is to have a web page
that shows a variable number of 'detail' lines. These are pulled from a
database. I put a server control on my page that internally renders the
HTML. It builds the entire page dynamically, since the # of detail lines is
not know until the actual order is pulled up. I have checkboxes on each of
the detail lines, so that a user can check a line, and click a button to see
more detail for that line.

The problem is, that since the entire page was built with dynamic HTML, I'm
having trouble finding out which line is checked. Currently, I have a couple
of lines of java script that determine which line is checked, put the value
in a cookie, and pass that to my C# program. It just seems to me that there
should be a way in my C# program to figure out which lines are checked.
Since this whole page is built dynamically, I don't have web controls or html
controls. Any ideas?

"Kevin Spencer" wrote:
When you say "running .Net," are you referring to the .Net platform, or, as
I asked, Visual Studio.Net?

In any case, the question is moot, since you want to do it programmatically.
Your best bet is to use WebControls or HtmlControls to do this. That is what
they are designed for. Any other solution is going to be problematic.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Sometimes you eat the elephant.
Sometimes the elephant eats you.

"Brian Kitt" <Br*******@discussions.microsoft.com> wrote in message
news:30**********************************@microsof t.com...
Yes, running .NET, but what I meant was I needed to get the value of the
controls in my C# program. Programatically I need to check the value of
the
controls. I can't figure out how to do it through any normal object.

"Kevin Spencer" wrote:
Hi Brian,

Do you have Visual Studio.Net? If so, three are oodles of ways to inspect
process and data in your app, using BreakPoints, Watches, etc.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Sometimes you eat the elephant.
Sometimes the elephant eats you.

"Brian Kitt" <Br*******@discussions.microsoft.com> wrote in message
news:C5**********************************@microsof t.com...
>I have a C# application that builds dynamic HTML and renders it.
>Because
>it
> is rendered in this way, the input controls are not server controls. I
> write
> the entire page, which has a variable number of detail lines for an
> order.
> I
> want the user to be able to change values on these detail lines and hit
> an
> 'update' button. I know how to do this in Javascript, but I'd like to
> be
> able to inspect the controls that come back to my C# program during a
> Postback. Since these are not server controls, they are not available
> in
> Page.Controls. What is the 'proper' way to inspect these inside of the
> compiled C# program? Right now I'm parsing them out through
> javascript,
> and
> passing them through cookies, but there has to be a better way than
> this,
> isn't there?


Nov 19 '05 #5

P: n/a
Hi Brian,

Okay, you say you "put a server control on my page that internally renders
the HTML." And "It just seems to me that there should be a way in my C#
program to figure out which lines are checked." Finally, you also mention
that you "have a couple of lines of java script that determine which line is
checked, put the value in a cookie, and pass that to my C# program." In
fact, you HAVE figured out a way in your program to figure out which lines
are checked.

Perhaps you are misunderstanding ASP.Net a bit, but you certainly know how
to solve a problem! And that is what a programmer (and a program) does. Let
me see if I can clear it up a bit for you and give you a better day.

ASP.Net is all about HTML and HTTP. What the server-side part of the app
does is to create HTML and respond to browser requests, in essence. In other
words, ASP.Net is about working in a stateless HTTP environment in which the
client is disconnected from the server, and HTML is the UI "language" if you
will. HTTP is all about messaging, sending messages back and forth between
the browser and the server.

So, in fact, an ASP.Net application has both a server-side and a client-side
aspect to it. The fact that the server-side code renders the client-side
HTML may be confusing you, but in fact, both are inseparable (although
separate) parts of the same application.

The built-in Microsoft Server Controls, as well as any custom Server
Controls you may create and/or use, do essentially what your solution does.
The only diffrence is in the methodology, and even that is similar. MS
Server Controls render both HTML and JavaScript, as JavaScript is almost the
only way to create a process on the client, in the browser. Server Controls
handle client-side events by creating and using JavaScript and hidden form
fields. The JavaScript on the client is wired up to client-side form
elements via JavaScript event handlers. When a button is clicked, for
example, a JavaScript event handler is fired that puts the ID of the button
into one hidden form field, and an "argument" or a set of arguments, if any,
into another. It then posts the form, which sends the form data, including
the event data, back to the server, where the server-side code reacts to it.

Your solution is proprietary, and doesn't follow the ASP.Net programming
model very closely, but it does essentially what the ASP.Net programming
model does. The ASP.Net programming model is more extensible, and follows a
design pattern that is extremely well thought-out. You may want to follow it
more closely in the future, but that is really of secondary importance to
solving the problem, which you have done quite well.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.
"Brian Kitt" <Br*******@discussions.microsoft.com> wrote in message
news:08**********************************@microsof t.com...
Maybe I'm approaching this wrong then. My end result is to have a web
page
that shows a variable number of 'detail' lines. These are pulled from a
database. I put a server control on my page that internally renders the
HTML. It builds the entire page dynamically, since the # of detail lines
is
not know until the actual order is pulled up. I have checkboxes on each
of
the detail lines, so that a user can check a line, and click a button to
see
more detail for that line.

The problem is, that since the entire page was built with dynamic HTML,
I'm
having trouble finding out which line is checked. Currently, I have a
couple
of lines of java script that determine which line is checked, put the
value
in a cookie, and pass that to my C# program. It just seems to me that
there
should be a way in my C# program to figure out which lines are checked.
Since this whole page is built dynamically, I don't have web controls or
html
controls. Any ideas?

"Kevin Spencer" wrote:
When you say "running .Net," are you referring to the .Net platform, or,
as
I asked, Visual Studio.Net?

In any case, the question is moot, since you want to do it
programmatically.
Your best bet is to use WebControls or HtmlControls to do this. That is
what
they are designed for. Any other solution is going to be problematic.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Sometimes you eat the elephant.
Sometimes the elephant eats you.

"Brian Kitt" <Br*******@discussions.microsoft.com> wrote in message
news:30**********************************@microsof t.com...
> Yes, running .NET, but what I meant was I needed to get the value of
> the
> controls in my C# program. Programatically I need to check the value
> of
> the
> controls. I can't figure out how to do it through any normal object.
>
> "Kevin Spencer" wrote:
>
>> Hi Brian,
>>
>> Do you have Visual Studio.Net? If so, three are oodles of ways to
>> inspect
>> process and data in your app, using BreakPoints, Watches, etc.
>>
>> --
>> HTH,
>>
>> Kevin Spencer
>> Microsoft MVP
>> ..Net Developer
>> Sometimes you eat the elephant.
>> Sometimes the elephant eats you.
>>
>> "Brian Kitt" <Br*******@discussions.microsoft.com> wrote in message
>> news:C5**********************************@microsof t.com...
>> >I have a C# application that builds dynamic HTML and renders it.
>> >Because
>> >it
>> > is rendered in this way, the input controls are not server controls.
>> > I
>> > write
>> > the entire page, which has a variable number of detail lines for an
>> > order.
>> > I
>> > want the user to be able to change values on these detail lines and
>> > hit
>> > an
>> > 'update' button. I know how to do this in Javascript, but I'd like
>> > to
>> > be
>> > able to inspect the controls that come back to my C# program during
>> > a
>> > Postback. Since these are not server controls, they are not
>> > available
>> > in
>> > Page.Controls. What is the 'proper' way to inspect these inside of
>> > the
>> > compiled C# program? Right now I'm parsing them out through
>> > javascript,
>> > and
>> > passing them through cookies, but there has to be a better way than
>> > this,
>> > isn't there?
>>
>>
>>


Nov 19 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.