Oh and to take the example further and get a client side dom reference to the select element rendered by server side asp:DropDownList, it would be more like this:
<script language="javascript" type="text/javascript"> var sControlID = '<%= ddlProducts.ClientID %>'; var dd = document.getElementById(sControlID); </script> or just <script language="javascript" type="text/javascript"> var dd = document.getElementById('<%= ddlProducts.ClientID %>'); </script> Cheers, Joe On 11/15/06, Joe Audette <[EMAIL PROTECTED]> wrote:
I think the main thing is you did figure out the right way to do it and thats what really matters :-) <script language="javascript" type="text/javascript"> var sControlName = '<%= ddlProducts.ClientID %>'; </script> To me that is the correct way in .NET to get a javascript reference to a .NET server control. If the other way did work on Windows I would consider that a surprising bug. My only other point is the above works with DropdownList, TextBox etc but not with a Literal control as a Literal control has no client id and therefore nothing to reference. Literal control just renders to the browser as literal markup. Cheers, Joe On 11/15/06, Travis Staloch <[EMAIL PROTECTED]> wrote: > > Joe, > > < > This doesn't work on my planet. On my planet you would never put > something like that in javascript. ... Putting runat=server in the string of > a javascript variable is just cuckoo here on my planet. No offense to other > worlds of course ;-), each to his own. > < > > I agree that its not the best form. Looking back at it now, it looks to > me like it shouldn't work. > > Should I report a bug on something like this? > > Regards, > > --Travis > > *Joe Audette <[EMAIL PROTECTED]>* wrote: > > Hi Travis, > > < > I really meant (single quotes replaced with double quotes). ** THIS > WORKS ** > var sControlName = "<asp:Literal id="lit1" runat="server" />"; > < > > This doesn't work on my planet. On my planet you would never put > something like that in javascript. A literal declared server side in markup > like <asp:Literal>id="lit1" Text="foo" /> would render in the browser only > as foo. Putting runat=server in the string of a javascript variable is just > cuckoo here on my planet. No offense to other worlds of course ;-), each to > his own. > > Cheers, > > Joe > > On 11/15/06, Travis Staloch < [EMAIL PROTECTED]> wrote: > > > > ****** > > Sorry all for the repost. I messed up the subject last time. > > --Travis > > ****** > > > > Joe, > > > > Thanks for the tip. I agree that using <%= is a simpler way to get > > that id into that file. However, the example below (1) _does_ work on > > windows. The example I sent before wasn't exactly what I'd used. I mixed > > some single qoutes with double quotes. I know its ugly, but it works. > > > > When I said (notice single quotes at beginning and end): > > var sControlName = '<asp:Literal id="lit1" runat="server" />'; > > > > I really meant (single quotes replaced with double quotes). ** THIS > > WORKS ** > > var sControlName = "<asp:Literal id="lit1" runat="server" />"; > > > > --Travis > > > > (1) - Example works on windows, not on linux mono. > > .aspx.cs > > ------------- > > protected Literal lit1; > > ... > > // in Page_Load() > > lit1.Text = "ControlName"; > > > > .aspx > > ------------- > > ... > > <script language="javascript" type="text/javascript"> > > var sControlName = "<asp:Literal id="lit1" runat="server" />"; > > </script> > > ... > > > > That would never work on windows either. Its not a correct way to get > > a > > client side reference to a server side control. Its not a Mono > > migration > > issue at all. > > > > Best Regards, > > > > Joe > > > > On 11/14/06, Travis Staloch wrote: > > > > > > FYI, > > > > > > I was able to solve this problem myself. I realized that it had to > > do > > > with the fact that I'd included some unnecessary mono assemblies in > > my web > > > app's bin directory (assemblies which were already in the GAC or > > otherwise > > > on the machine which I migrated to). > > > > > > This caused some confilcts as I'm guessing that mono found these > > private > > > assemblies in my app's bin directory before finding the shared > > assemblies > > > elsewhere. I think that what happened is some 1.18 or 1.16assemblies ( > > > Mono.Data.Tds.dll in the error below) were used by the 1.15 mono > > > installation. > > > > > > Another problem, and possible bug, I noticed with my web app (a > > difference > > > from windows .NET) was that I had problems using an to > > > set a javascript variable. Here is the code which gives me a > > > NullReferenceException when I try to use it. > > > > > > THIS DOESN'T WORK: > > > .aspx > > > -------- > > > > > > .cs > > > -------- > > > protected Literal litProductDdlName; > > > ... > > > litProductDdlName.Text = ddlProducts.ClientID; > > > > > > > > > THIS WORKS - using <%= %> escaping as a workaround: > > > .aspx > > > -------- > > > > > > > > > After making this change, I have been able to successfully run my > > migrated > > > ASP.NET web app on apache2/mod_mono. > > > > > > Regards, > > > > > > --Travis > > > > > > > > > *Travis Staloch * wrote: > > > > > > Guys, > > > > > > I've recently moved a .NET 1.1 web application over from a working > > > windows/IIS machine to a linux/apache2/mod_mono machine. I keep > > > > > > getting this message whenever I try to view any of the pages: > > > > > > System.MissingMethodException: Method not found: > > > 'Mono.Data.Tds.Protocol.TdsConnectionParameters.Reset'. > > > in <0x00000> > > > > > > I was getting a System.TypeLoadException error from same > > > assembly (Mono.Data.Tds) until I restarted apache2. > > > > > > Does anyone have any ideas what might be causing this? > > > Is this related to the fact that the linux machine has mono > > > 1.1.15 installed while the windows machine the app migrated > > > from had a later version (1.1.18 I think)? > > > > > > Regards, > > > > > > --Travis > > > > > > ------------------------------ > > > Want to start your own business? Learn how on Yahoo! Small Business. > > > > > > > > > ------------------------------ > > > Everyone is raving about the all-new Yahoo! Mail beta. > > > > > > > > > _______________________________________________ > > > Mono-list maillist - Mono-list@lists.ximian.com > > > http://lists.ximian.com/mailman/listinfo/mono-list > > > > > > > > > > > -------------- next part -------------- > > An HTML attachment was scrubbed... > > URL: > > http://lists.ximian.com/pipermail/mono-list/attachments/20061114/22bced4f/attachment.html > > > > ------------------------------ > > > > _______________________________________________ > > Mono-list mailing list > > Mono-list@lists.ximian.com > > http://lists.ximian.com/mailman/listinfo/mono-list > > > > > > End of Mono-list Digest, Vol 19, Issue 19 > > ***************************************** > > > > > > ------------------------------ > > > > > > > > ------------------------------ > > Everyone is raving about the all-new Yahoo! Mail beta<http://us.rd.yahoo.com/evt=42297/*http://advision.webevents.yahoo.com/mailbeta>. > > > > > > _______________________________________________ > > Mono-list maillist - Mono-list@lists.ximian.com > > http://lists.ximian.com/mailman/listinfo/mono-list > > > > > > > > ------------------------------ > Sponsored Link > > Mortgage rates near 39yr lows. $420,000 Mortgage for $1,399/mo - Calculate > new house payment<http://www.lowermybills.com/lre/index.jsp?sourceid=lmb-9132-16414&moid=4116> > > _______________________________________________ > Mono-list maillist - Mono-list@lists.ximian.com > http://lists.ximian.com/mailman/listinfo/mono-list > > >
_______________________________________________ Mono-list maillist - Mono-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-list