troubleshooting Question

Finding HtmlInputText in c# 2.0

Avatar of tia_kamakshi
tia_kamakshiFlag for United Arab Emirates asked on
11 Comments2 Solutions1405 ViewsLast Modified:

I am working on 2.0 using c#

I am creating form on the aspx page by transforming xml with xslt and therefore creating html conrols in the form

I have created html text field from xml , xslt as follows

<input type="text" name="txtCompanyName" runat="server" class="formText" />

Now at code behind I am writting a code on page load method (just to test if code is finding html control or not)

HtmlInputText hCompany = (HtmlInputText)Page.FindControl("txtCompanyName");
string txtCompanyName = hCompanyName.Value;

I am getting null pointer exception because hCompany is null

I have also tried

HtmlInputText hCompany = (HtmlInputText)this.FindControl("txtCompanyName");

but it is not working

I am rendering xml with xslt on aspx page by below code:

<asp:Xml runat="server" ID="tblTenderDetail" Document="myxml.xml"  TransformSource="tenderDetail.xsl" >

I also tried

HtmlInputText hCompany = (HtmlInputText)tblTenderDetail.Page.FindControl("txtCompanyName");

Please guide

Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 2 Answers and 11 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 11 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros