Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 29th, 2007, 08:45 PM
Registered User
 
Join Date: Nov 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default convert old html form

Hi, please have patience with me i am newish to c#

I would like to convert an old form, here is a sample text field:

Last Name:<input type="text" id="lname" name="lname" class="inputStyleA" value="<%=lname>" onchange="this.value = initialCap(this.value);" />

Now in the codeBehind page i have the following which does not work:

protected void Page_Load(object sender, EventArgs e)
{
string lname = "asdfasdf";
.....

Question: is it possible to preserve the html code and get it going from the codebehine... that is pass the value to the html page?

Thanks
 
Old November 29th, 2007, 09:15 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

O.o The answer to your question is yes, but I do not agree with this approach.

You must declare your string variable outside of all your methods and place it in the body of your class.

public partial class foo
{
   public string lname;
}

You should then be able to access the value from your ui.

Personally i would just rewrite the form:

Last Name: <asp:TextBox id="lname" CssClass="inputStyleA" runat="server" />

protected void Page_Load(object sender, EventArgs e)
{
   if(!Page.IsPostBack)
   {
      lname.Text = "foo";
      lname.Attributes.Add("onChange", "this.value = initialCap(this.value);");
   }
}

Course that is just me.
hth.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor :.
Wrox Books 24 x 7
================================================== =========
 
Old November 29th, 2007, 10:11 PM
Registered User
 
Join Date: Nov 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

i tried to re-write but this thing but a designer made the page, using multiple form tags wrapped in divs, that is how the menu systems was designed: display:block / display:none

It turned out that more than 1 form on the page doesn't work, the menu consists of 8 page with 80 form fields in each (many lines of html for this one page :( even visual studio is accting slow on the backspace. I need to move forward with this one....

I appreciate you response, and ideology for layer seperation.

Thanks
 
Old November 29th, 2007, 10:50 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

O.o 640 Form Fields? Wow.

In any event, a .aspx page can only have one <form runat="server"> control. I have not used a regular HTML <form> tag in a long time so I am not sure how Visual Studio behaves with them. Personally I think you are better off rewriting the data elements and the forms because, IMHO, you are only going to Band-Aid the situation so that it "works", you are not actually fixing the problem.

In the long run it is probably better to take the time now and rewrite the forms using server controls and such then having to come back and maintain the pages later.

Just my opinion anyway.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor :.
Wrox Books 24 x 7
================================================== =========





Similar Threads
Thread Thread Starter Forum Replies Last Post
convert html file to pdf kanwaldeep ASP.NET 1.0 and 1.1 Professional 0 October 25th, 2007 11:50 AM
how to convert html to chtml bina HTML Code Clinic 2 March 1st, 2007 11:20 PM
convert Html in aspx page prashantraizada2002 ASP.NET 1.0 and 1.1 Basics 1 June 24th, 2006 04:55 PM
convert HTML in aspx prashantraizada2002 ASP.NET 1.0 and 1.1 Basics 1 June 8th, 2006 11:44 AM
Convert to HTML Format thomaz C# 0 October 28th, 2004 01:36 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.