Home
Get Started
Learn
Downloads
AJAX
MVC
Community
Wiki
Forums
Sign in
|
Join
Home
›
ASP.NET Forums
›
Search
Search
You searched for the word(s): userid:762892
More Search Options
RSS Available
Matching Posts
Javascript and inline c#
I need to call a c# method from javascript and I am having problems with the syntax. Appraiser.Templates is an enum. I am refering to the enum to get the name of the page. public enum Templates { StaffTemplate = 1, SupervisoryTemplate = 2 } This code works: < script language ="javascript" type ="text/javascript"> function openWinNew() { var ddlTemplatesIndex = document.getElementById( 'ddlTemplates' ).options[document.getElementById( 'ddlTemplates' ).selectedIndex
Posted to
Client Side Web Development
(Forum)
by
forwheeler4
on 7/9/2009
Re: Javascript and inline c#
[quote user="srinivaskotra"] Hi, you have to change this code window.open( 'Templates/<%=System.Enum.GetName(typeof(Appraiser.Templates), %>ddlTemplatesIndex.value<%=)%> .aspx 'newtemplate' , '' , '' ); to window.open( 'Templates/'+ddlTemplatesIndex.value+'.aspx 'newtemplate' , '' , '' ); Thanks :) [/quote] Thanks srinivaskotra. That will not give me the name of the page from the enum but the index of the ddlTemplatesIndex
Posted to
Client Side Web Development
(Forum)
by
forwheeler4
on 7/9/2009
Re: Javascript and inline c#
Thanks for the reply agr001. The System.Enum.GetName(typeof(Appraiser.Templates) in the Page_Load is not going to compile. I want to have the ddlTemplatesIndex.value from the JS as a parameter to the GetName method.
Posted to
Client Side Web Development
(Forum)
by
forwheeler4
on 7/9/2009
Re: Javascript and inline c#
Accessing the page name from the enum works fine on my other code pages - the issue is trying to access it from JS. It is really not an enum problem but my lack of knowledge in concatinating this string to access both client and server code. window.open( 'Templates/<%=System.Enum.GetName(typeof(Appraiser.Templates), 1)%> .aspx 'newtemplate' , '' , '' ); The above code works. The problem is the syntax for replacing the 1 in the above code with the dropdownlist value
Posted to
Client Side Web Development
(Forum)
by
forwheeler4
on 7/9/2009
Re: Javascript and inline c#
Yes, I can get the value from the code behind page. That is no problem. The problem is passing the dropdownlist value(javascript) as a parameter to the method in the c# code. The server method is Enum .GetName( typeof ( PrintTemplates ), [DROPDOWNLIST VALUE HERE]); The method is not complete because I broke it as noted below. I need to place the dropdownlist value as the parameter in the method as noted. window.open( 'Templates/) Server(<%=System.Enum.GetName(typeof(Appraiser.Templates),%>
Posted to
Client Side Web Development
(Forum)
by
forwheeler4
on 7/9/2009
Re: Javascript and inline c#
[quote user="agr001"] if ddlTemplates is an asp.net serverside dropdown then use var ddl = document.getElementById('<% =ddlTemplates.ClientID %>'); Have a look at the browser source code to see why i keep mentioning the clientID. asp.net assigns these id's to the asp.net controls [/quote] Yes I understand and I can get that value just fine.
Posted to
Client Side Web Development
(Forum)
by
forwheeler4
on 7/9/2009
Re: Javascript and inline c#
[quote user="jamezw"] You could write some server side code to render the enumeration as a JavaScript array like so: view plain copy to clipboard print ? protected void Page_PreRender( object sender, EventArgs e) { ClientScriptManager clientScript = Page.ClientScript; StringBuilder arrayValue = new StringBuilder(); Appraiser.Templates[] enumValues = Enum.GetValues( typeof (Appraiser.Templates)).Cast<Appraiser.Templates>().ToArray(); for ( int i = 0; i < enumValues.Length; i++)
Posted to
Client Side Web Development
(Forum)
by
forwheeler4
on 7/9/2009
Re: TinyMCE / Ajax Postback Problem
I am trying to use steho706's code and it works for the first callback but if I save the page again I get a permission denied error in the tiny_mce js. Is there a workaround for this error?
Posted to
ASP.NET AJAX Discussion and Suggestions
(Forum)
by
forwheeler4
on 4/28/2009
Re: Set textbox text on aspx from ascx
I set the notifier event to static and now the notifier is not null. The template_notifier method gets called multiple times almost like a postback for one button click so I'm not sure why that is happening.
Posted to
Web Forms
(Forum)
by
forwheeler4
on 4/15/2009
Re: Set textbox text on aspx from ascx
Thanks for the code. My notifier is always null on the user control. I am using a base class for my aspx page so I can use one code page for 2 pages. To declare the event handler on the base page, I needed a reference to the user control. I tried your ucMenu.notifier += new DelPassText(template_notifier) and I couldn't get a reference to the notifier. I used a reference to the Menu class instead like Menu menu = new Menu(); menu.notifier += new DelPassText(template_notifier) I don't think
Posted to
Web Forms
(Forum)
by
forwheeler4
on 4/15/2009
Page 1 of 2 (18 items) 1
2
Next >
Channel 9:
TWC9: 2009 - The Year in Review
ASP.NET:
Tip#100: Did you know… How to view ASP.NET trace information?
ASP.NET:
Passing anonymous objects to MVC views and accessing them using dynamic
Channel 9:
Channel 9 Live at PDC09: Coding 4 Fun
Channel 9:
Channel 9 Live at PDC09: Stephen Toub
WindowsClient:
Mouse Gestures for Internet Explorer
Channel 9:
Controlling concurrency in Rx
Channel 9:
Dev Tools Ecosystem Summit Videos Available
WindowsClient:
Using Cerebrata's Cloud Storage Studio To Download IIS logs from Multiple Instances of Windows Azure
TechNet Edge:
TechNet Radio: Office 2007 Setup and Configuration (Part 1)
Channel 10:
How-To: Listen to Your Zune Pass Music on Your WinMo Phone
Channel 10:
Share Your Screen with SharedView
Channel 10:
Get Microsoft Tinker Game For Free
Channel 10:
LG eXpo WinMo 6.5 Unboxing Video
Channel 9:
ADFS 2.0 RC is Here!
Channel 10:
Bing Reference Updated with New Sidebar Features
Channel 10:
Look Behind SurfaceScapes
ASP.NET:
Moving your ASP.NET Application to Windows Azure – Part I
TechNet Edge:
Windows Server 2008 R2 Quick Look- Installing the Migration Tools
WindowsClient:
My latest videos – WPF, Silverlight, Sensors, and PDC09
Microsoft Communities
ASP.NET
Channel 8
Channel 9
Channel 10
IIS.NET
Silverlight
TechNet Edge
WindowsClient
Mix Online