tia_kamakshi
asked on
Finding HtmlInputText in asp.net c# 2.0
Hi,
I am working on asp.net 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.FindCo ntrol("txt CompanyNam e");
string txtCompanyName = hCompanyName.Value;
I am getting null pointer exception because hCompany is null
I have also tried
HtmlInputText hCompany = (HtmlInputText)this.FindCo ntrol("txt CompanyNam e");
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="tenderDet ail.xsl" >
I also tried
HtmlInputText hCompany = (HtmlInputText)tblTenderDe tail.Page. FindContro l("txtComp anyName");
Please guide
I am working on asp.net 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.FindCo
string txtCompanyName = hCompanyName.Value;
I am getting null pointer exception because hCompany is null
I have also tried
HtmlInputText hCompany = (HtmlInputText)this.FindCo
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="tenderDet
I also tried
HtmlInputText hCompany = (HtmlInputText)tblTenderDe
Please guide
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
yes oCompany is also null
It is under contentPlaceHolder as aspx page has masterpage in it
so the code is
<asp:Content ID="Content6" ContentPlaceHolderID="Main Content" runat="Server">
<asp:Xml runat="server" ID="tblTenderDetail" Document="myxml.xml" TransformSource="tenderDet ail.xsl" >
</asp:Xml>
</asp:Content
It is under contentPlaceHolder as aspx page has masterpage in it
so the code is
<asp:Content ID="Content6" ContentPlaceHolderID="Main
<asp:Xml runat="server" ID="tblTenderDetail" Document="myxml.xml" TransformSource="tenderDet
</asp:Xml>
</asp:Content
ASKER
As suggested I have added name and id both as follows:
<input type="text" id="txtCompanyName" name="txtCompanyName" class="formText" />
and tried
HtmlInputText hCompany = (HtmlInputText)Page.Master .FindContr ol("txtCom panyName") ;
This also not helped me
Please suggest
<input type="text" id="txtCompanyName" name="txtCompanyName" class="formText" />
and tried
HtmlInputText hCompany = (HtmlInputText)Page.Master
This also not helped me
Please suggest
ASKER
I have the inputs in xml only. This xml is published by external agency, therefore xml and xslt is used
Do you have any suggestion other than this
Please suggest that as well
Do you have any suggestion other than this
Please suggest that as well
Run the page, do a View Source, and put that output here for us to look at.
Post your xml and xslt please, to give you another approach
ASKER
Hi,
Please find my code attached.
I have renamed all files with .txt extension at the last. so that experts exchange should allow me to upload the file
Please suggest
code.zip
Please find my code attached.
I have renamed all files with .txt extension at the last. so that experts exchange should allow me to upload the file
Please suggest
code.zip
ASKER
hi
are you looking into this? this is urgent to me
please guide
thanks
are you looking into this? this is urgent to me
please guide
thanks
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks Dan7el
I have now added form tag having runat server in it.
The problem looks to me is related to
https://www.experts-exchange.com/questions/27240176/runat-server-is-not-working-when-transforming-xml-and-xslt.html
my html control is not running at server, therefore it is displaying runat server with input tag. means .net is not rendering this control on the server and taking output as string after transformation of xml and xslt
Please suggest
I have now added form tag having runat server in it.
The problem looks to me is related to
https://www.experts-exchange.com/questions/27240176/runat-server-is-not-working-when-transforming-xml-and-xslt.html
my html control is not running at server, therefore it is displaying runat server with input tag. means .net is not rendering this control on the server and taking output as string after transformation of xml and xslt
Please suggest
object oCompany = Page.FindControl( "txtCompanyName" );
What is oCompany? Null?
Also, is this inside any other control like a repeater or such?