Create A File Of Constants In Javascript?
Jun 30, 2010
Is there a way to create a file of constants in JavaScript, which I can reference and then use?
What I am looking for is something like this:
Constants.js:
var Phones =
{
Nokia: 1,
Samsung: 2
}
Then, in another JavaScript file JS2.js access those values:
JS2.js:
alert(Phones.Nokia);
And then, in an aspx file that uses them, reference both of them, like:
<asp:ScriptReference Path="../js/JS2.js" />
<asp:ScriptReference Path="../js/Constants.js" />
Is such an architecture possible? What datatypes can we use? I only exemplified enums because this is what i use right now, but they must be declared in the same file as they are used.
View 2 Replies
Similar Messages:
Mar 8, 2010
It is possible to create a constant like this:
[URL]
<%@ Page CompilerOptions="/d:QUUX" %>
How to create multiple constants ?
View 1 Replies
Dec 8, 2010
I have a database table that contains list of all UserTypes(constant strings) used in the application.
What is the best way to store(what datastructure do I need) these so that code can access them ?
The need is similar to enum, but I want to associate these values to those in DB so that there will not be 2 places to edit in case of adding/removing an entry.
one other option I considered is using public static readonly string, but how to associate with those values in DB ?
View 3 Replies
Oct 22, 2010
How can i use the .net Default folder App_GlobalResources Folder to store a Resource file which contains all the Page names?
Currently i added a a Resource file (PageNameConstants.resx) and set the name filed and Value field but i cannot access any of those by calling
App_GlobalResources.PageNameConstants.HOME(HOME has the value ~/Home.aspx)
View 1 Replies
May 14, 2012
How to create object of class file (asp.net) using javascript and call is methods.
View 1 Replies
Jan 8, 2011
I have written a smal HtmlHelper, but the thing is that I whould require some javascript functionallity to this helper. So I thought "Whouldnt it be great to actually let the framework add the javascript <script>-tag to the head-element of my Html document once I use this helper?"
So what I whould need/like to do is:
1. Add the Javascript-file as a resource to the dll, since this will allow me to always have the javascript file together with my HtmlHelper, so I dont need to have a seperate file for the js.
2. Add a <script src="{my js-resource}" /> to the head-element of my html document as soon as I use my helper...this is kind of the tricky part..since Im not realy sure about how to do this in MVC...if its even possible..the best sulotion whould be if I didnt need to add any other code in any other file then just in my HtmlHelper...(no code needed to be added in my views or controls) To put it all kind of simple...from what I recall..I want to more or less register a start up script, as its called in WebForms..but in MVC..(I saw an example of how to do it ClientScriptManager, but that whould require me to add extra code on my views and layout/masterpage-files...which simply doesnt do it for me if there is any other way)
View 3 Replies
Dec 31, 2010
I wonder what is the best place to store the enums I should use like constants in my n-tiers Application.
So I have an application with a DAL(connect to database), a BLL(Business processes), a Data Transfert object "Layer" (classes without any methods but just fields, this one is reacheable by all the others) and the interface layer with the asp pages.
My question is : I have a enum:
[code]....
Where can I put this enum(and all the others) to be clean? Not in the Data Access Layer the Interface layer will not see the struct, not in the Business Logic Layer, this is not really business.. Maybe in the Data Transfert Object but is it really a "Transfert object"?
View 7 Replies
May 31, 2013
I am doing an AJAX call back to a WebMethod but in the code behind webmethod I cannot use any of the constants at the to of my form. What I want is to gain access to sessions and my sql connection string.
View 12 Replies
Aug 27, 2010
I want to know what "<% =QDAB.Constants.SiteURL %>" means in the following line of code in my aspx page. I did google and didn't really find any information on this.
<td align="center" style="background-image: url(<% =QDAB.Constants.SiteURL %>images/Docs/Plans/myImage.jpg);
So what exactly does this mean?
[Aditional Details]
I changed url(<% =QDAB.Constants.SiteURL %>images/Docs/Plans/myImage.jpg);
to this url(<% =QDAB.Constants.SiteURL %>images/myImage.jpg);
I copied myImage in the "Images" folder.
Why would it access the image from "Images" folder BUT NOT "Images/Docs/Plans"?
View 3 Replies
Jan 27, 2011
I have two user controls and both the user controls refer a same script path:
<script type="text/javascript" src="test.js"></script>
then what happens when the first user controls load then test.js will download in client and when second user control loads then test.js file will download again.
How do I check to see if the JavaScript file is already downloaded so it doesn't have to be downloaded again?
If I include the JavaScript file from the server side:
Page.ClientScript.RegisterClientScriptInclude("test",
Page.ClientScript.GetWebResourceUrl(this.GetType(),
"test.js"));
then how could I make sure it isn't included twice?
View 1 Replies
Mar 23, 2011
I create a pdf, then I set NavigateUrl with the path. The file is opened, but if I re-create it, ie open the temp file pdf, don't reload the new.. Only after some minutes (I don't refresh the page) ie re-download the new pdf..How can I force to open always the file on the server?
View 2 Replies
Mar 24, 2010
How to enable a batch file to create output file on the Server side?
View 1 Replies
Jul 25, 2010
I have an asp.net application. I want to add a global.asax and global.asax.cs file to my project. In the IDE when I select to create a new global.asax file, the option to create a CS code behind file is greyed out. When the global.asax file is created, no code behind is created, instead code is placed in the global.asax file and the global.asax.cs file is never created? Why is the option for a C# code behind file greyed out?
View 4 Replies
Sep 13, 2010
How do I create a schema.ini file from a tab delimited file?
I have this so far:
[myFile.txt]
ColNameHeader=True
Format=TabDelimited
CharacterSet=ANSI
I think I need something like this after my last line from above:
Col1=first TEXT width 150
My text file has 7 columns, the first row is the header row. The data comes from a Micosoft SQL Server Database where the fields are of the following types:
int
nvarchar(MAX)
nvarchar(50)
View 1 Replies
May 28, 2010
Just wondering if there is a way to create a file using open filedialogue. I actually need a functioanlity a little bit different from Save Dialog. I have to use OpenFile dialogue because I want user to select file. In addition to this, if the file is not available and user just write a name of the file then it should pop-up like "File not found, would you like to create one?
View 2 Replies
Jul 19, 2010
I have the following code for creating a file if it does not exist and overwriting it if it already exists:
FileStream fsExe = File.Create(DestExePath, 4096);
BinaryWriter bw = new BinaryWriter(fsExe);
What ever I write to the BinaryWriter, it is getting appended to the "DestExePath" instead of overwriting the original file.
View 6 Replies
Jan 13, 2011
I'm using System.IO.File.Create to create a file. I'm not writting to it with a stream writer, just creating it.
I get a server error in the front end when the app trys to open the newly created file - that the file is in use. Garbage collection then seems to come along and a few minutes later all is OK.
Now I know if I was using Streamwriter I would have to close it. Does the same apply to creating?
I've read that opening a stream writer to the file then immediately closing it will fix this.
View 4 Replies
Mar 17, 2010
I'm working on an MVC application and I ran into a little snag.
I've got a form with the usual textboxes and dropdowns. I decided to use jquery ajax (GET) to load the dropdowns on load (State Names & Salutations).
No matter what I try, for example:
Code:
<AcceptVerbs(HttpVerbs.Get)> _
Public Function ReturnSalutationDropdown() As ActionResult
Dim dropdown As New DropDownList With {.TabIndex = 1, .DataTextField = "Value", _
.DataValueField = "Key", .ID = "ddl_coSalutation"}
dropdown.DataTextField = "Value"
dropdown.DataValueField = "key"
dropdown.DataSource = AppEnumerations.BindToEnum(GetType(AppEnumerations.Salutation))
dropdown.DataBind()
Dim sb As New StringBuilder
Dim tw As New IO.StringWriter(sb)
Dim hw As New HtmlTextWriter(tw)
dropdown.RenderControl(hw)
Return Content(sb.ToString)
End Function
The ID of the dropdown ends up like: ctl00$MainContent$ddl_coSalutation
It doesn't matter if I use a stringbuilder and a loop to create a <select> with <option>'s, the ID always ends up like above.
Do I have to create a javascript function to create it instead?
View 5 Replies
Sep 20, 2010
I need to create chart using javascript.
should be look like as in link below (click play to see chart sample):
which control should i use/purchase, which allows me to create chart in such style shown in link.
chart data will be in xml format and i am asp.net developer
View 9 Replies
Jan 4, 2010
I am using Directory.Move() and am getting the following error "Cannot create a file when the file already exists". I am passing 2 params:
Code:
Param1 = "D:IntegrationSiteImagesFolder1"
Param1 = "D:IntegrationSiteImagesFolder2"
View 2 Replies
Mar 26, 2011
I am trying to create a toolbar on top of my website to be used on an iphone. However, iframe is giving me considerable trouble in that it refuses to allow the page to scroll. Here's my code:
[code]....
View 1 Replies
Dec 9, 2010
How to register a Java Script varibale in Server Side (Code behind ) and access at Client side (Javascript file ) , without a hiddenfield , Literal etc
View 4 Replies
Aug 4, 2010
I have a search page that is used in multiple places with multiple 'themes' throughout my site. I have a few divs that can have their background color changed based on a radio button selection (whether they are enabled or not). I can do this just fine by changing the css class of the div on the fly with javascript.
However, these themes could potentially change, and the background color is grabbed from a database when the page is created. Right now I do this in the C# codebehind:
string bgStyle = "background-color:" +theme.searchTextHeaderColor +";";
OwnerSearchHeader.Attributes.Add("style", bgStyle);
In the Javascript I need to change this color to make it look disabled, and when the user clicks back to this div I need to re-enable it by changing it back to its original color. But since I only knew this color in the code-behind, I don't know what it was in the Javascript.
So my thought was to create a css class in the resulting HTML page when the page is loaded with the background color I need. Then I could simply switch from the divEnabled and divDisabled class in the javascript. But I'm not exactly sure how to do that.
View 2 Replies
May 6, 2010
I have a complex webform with a dynamic number of controls. I need to create some of them dinamically. There is no problem with asp.net validators, texbox, dropdownlists... but I can't find the way to do it with the autocompleterextender.
View 6 Replies
May 23, 2010
As a test, I wanted to have an ASP.NET page rendered without the auto-generated javascript. Is this possible?
View 2 Replies