Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 .net renames my webforms

Author  Topic 

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2008-01-21 : 17:27:50
Hello,

I have webform and named a textbox "taMessage" however at runtime, .net changes the ID name and appends other characters. I have tried adding and renaming the textbox, but its all the same results.

Please advice

my code is here


Its meant to be a textbox


class=formsBr ID="taMessage1" onkeydown="return keepLimit(0);" onkeyup="return keepCount(0);" runat="server" Height="107px" Width="224px">
"taMessage" runat="server" Height="65px" Width="219px">

and the results are thus

HTML4Strict Code:
<td class="style6" style="text-align: left">
<input name="ctl00$main$taMessage1" type="text" id="ctl00_main_taMessage1" class="formsBr" onkeydown="return keepLimit(0);" onkeyup="return keepCount(0);" style="height:107px;width:224px;" />
<input name="ctl00$main$taMessage" type="text" id="ctl00_main_taMessage" style="height:65px;width:219px;" />
</td>

tmitch
Yak Posting Veteran

60 Posts

Posted - 2008-01-22 : 23:25:45
Yes, the names of page objects are named dynamically at runtime. What are you trying to accomplish?

---------------------

Tim Mitchell
Mitchell Information Consulting : www.mitchellic.com
Go to Top of Page

mukunda
Starting Member

4 Posts

Posted - 2008-01-24 : 08:33:29
Yes the Id's are names dynamically at run time. If you are trying to get the value of the particular control in the javascript observe that each id is appended with constant value like "ctl00$main$" append this to ur control id which u are given in the aspx page. and get that value for Ex:

try this:-

var cid="ctl00$main$"+"taMessage1"
var obj=document.getElementById(cid).value

Thanks
Mukund
Go to Top of Page

JBelthoff
Posting Yak Master

173 Posts

Posted - 2008-01-26 : 07:59:02
Well, sounds like you are using Master Pages. Regardless, your controls will be in a "collection" somewhere.

Asp.Net utilizes the FindControl method to find those controls.

Take a look at this:
TextBox txtEmail = (TextBox)Page.PreviousPage.Master.FindControl("txtLoginEmail");


Also read up here: http://msdn2.microsoft.com/en-us/library/xxwa0ff0.aspx

This should get you started.







JBelthoff
• Hosts Station is a Professional Asp Hosting Provider
› As far as myself... I do this for fun!
Go to Top of Page

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2008-01-28 : 04:49:47
Thanks guys,
what i did was to insert the page.databind property and use the <%%> in my javascript events.
Go to Top of Page
   

- Advertisement -