473,385 Members | 1,492 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,385 software developers and data experts.

Discovering fields in a webform

I need to write an application in C# that can accept a WebForm. I am
assuming the WebForm would need to be accessed in design mode. I need to
recursively iterate through the fields in the form, including the fields in
the web usercontrols on the form.

I am using the .NET framework 2.0 and VS 2005Beta2.

This is what I noticed when the form fields were rendered at runtime

On a Form the fields for example

<asp:TextBox ID="WCTextBox1" runat="server"></asp:TextBox>

were rendered as

<input name="TextBox1" type="text" id="TextBox1" />

while form objects contained in web usercontrols (named WebUserControl1 on
the form)

<asp:TextBox ID="WCTextBox1" runat="server"></asp:TextBox>

were rendered as

<input name="WebUserControl1$WCTextBox1" type="text"
id="WebUserControl1_WCTextBox1" />

I need to create a unique list of all the form fields application wide to
create text values for them as well as assign security to the individual
elements.

How would I go about achieving this?

Thanks in advance

Sanjay


Nov 19 '05 #1
4 1022
Sanjay,

When your asp.net page is loaded all the form fileds and any
contiguous text are parsed and built into a tree of control classes.
You can recurse through the control tree, do some type checking for
what you want to do and get/set values.

e.g private void LoopThroughControls(Control control){

for each (Control ctrl in control.Controls){
if (ctrl is TextBox)
(TextBox)ctrl).Text = "Your text";

if (ctrl is WebControl && nosecurity)
(WebControl)ctrl.disabled = true

if (ctrl.Controls.Count > 0) LoopThroughControls(ctrl);
}
}
HTH,
Souri

Nov 19 '05 #2
Souri,

But what if you wanted to pass the assembly to another application that
wanted to process the form objects via reflection or something along those
lines?

thanks

Sanjay
"souri challa" <so*********@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Sanjay,

When your asp.net page is loaded all the form fileds and any
contiguous text are parsed and built into a tree of control classes.
You can recurse through the control tree, do some type checking for
what you want to do and get/set values.

e.g private void LoopThroughControls(Control control){

for each (Control ctrl in control.Controls){
if (ctrl is TextBox)
(TextBox)ctrl).Text = "Your text";

if (ctrl is WebControl && nosecurity)
(WebControl)ctrl.disabled = true

if (ctrl.Controls.Count > 0) LoopThroughControls(ctrl);
}
}
HTH,
Souri

Nov 19 '05 #3
Sanjay,

Tell me a little more about this other application and what exactly
you're trying to achieve? Are you trying to parse an ASPX page in a
windows or console app? In this case I would still try to use asp.net
environment/classes to dynamically create a page class and parse it.

-Souri

Nov 19 '05 #4
Souri,

Yes, that is exactly what I was hoping to do. I was writing a console app
that would load the assembly dll and by reflection traverse though the
classes in the assembly and based on the types, perform a set of tasks.
I was actually traveling down that path when I discovered that in .NET 2.0,
the wizard that publishes the pages creates partial dlls which are not
really assemblies, I am trying to figure out how to create the .net1.x style
bin dlls.

Sanjay
"souri challa" <so*********@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
Sanjay,

Tell me a little more about this other application and what exactly
you're trying to achieve? Are you trying to parse an ASPX page in a
windows or console app? In this case I would still try to use asp.net
environment/classes to dynamically create a page class and parse it.

-Souri

Nov 19 '05 #5

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

Similar topics

1
by: nuve | last post by:
Hi Please help.. What I want to do is to create a web form that once submitted it takes the fields and opens a new instance of a Word Template and populates bookmarks within the document with the...
0
by: Andrew | last post by:
Hi, Until now, I have used a single webform for my web app, and everything's been OK. Now, I've decided to create a main menu webform. So, I've got two webforms. Using Visual Studio .NET (with...
1
by: Sam Fisher | last post by:
Hi again is there any way to prevent the discovering of my web service (esp. by browser)? It would be perfect if only my own- written client could connect to the web service and no one else. As this...
0
by: Sanjay Pais | last post by:
I need to write a application in c# that would accept a web assembly with forms and web controls. It should then loop through the forms and create a list of the static objects. For web controls on...
1
by: Zameer Syed | last post by:
I have a webform in which users enter their information and there is a button at the end of form,which when clicked should open a word document with fields filled in dynamically with the...
3
by: | last post by:
All the fields in webforms are automatically declared as protected. If I change them to public, they are converted back to protected. Why is this happening ? Thanks
7
by: Holger (David) Wagner | last post by:
Hi Group, I've searched the Web for precompilers that compile ASPX/ASCX pages just like it can be done with JSPs, but so far, I've only found approaches targetted at increasing the performance....
2
by: Learner | last post by:
Hello, I am trying to store the data entered in a webform in the database. I have few Int and one SmallDateTime filed in my table in SQL Server 2005 database. I have made a storedproc to store the...
5
by: =?Utf-8?B?UGF1bA==?= | last post by:
Hi I have start web form and when the user clicks a button (server.transfer) they are directed to the second webform. I was wondering if there is a way to create an instance of the first webform...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.