Tracking Forums, Newsgroups, Maling Lists
Home Submit Tracker Forums
  Advanced Search
  HOME    TRACKER    ASP.NET


Advertisements:










C# - How To Access HttpContext.GetGlobalResourceObject() In Javascript(.js) File


I am using javascript file for validtion. Now I have to localize that javascript file. I want to HttpContext.GetGlobalResourceObject() in .js file. Can I use HttpContext.GetGlobalResourceObject() in my .js file? Is there any other option to locaize javascript file.


View 1 Replies (Posted: May 4 10 at 5:32)

Sponsored Links:

Related Forum Messages For ASP.NET category:
MVC :: How To Use GetGlobalResourceObject
I new a mvc project from template , and add the GlobalResource folder and MyString.resx file .

I write the code in the Site.Master :

<h1><% =GetGlobalResourceObject("MyString", "Title"); %></h1>

But it throw HttpParseException

:xxxxx . error CS1026: ) expected

Posted: Sep 19, 2009 02:30 AM

View 4 Replies!   View Related
C# - How To Access HttpContext.Current.Application
i have problem accessing HttpContext.Current.Application From global.asax its seems to be null every time i try to access it. How can i to this?

HttpContext.Current.Application.Lock();
HttpContext.Current.Application["Actions"] = "hello";
HttpContext.Current.Application.UnLock();

Posted: Jun 7 10 at 10:55

View 2 Replies!   View Related
How To Access Cache When No HttpContext.Current Is Available
During Application_End() in Global.aspx, HttpContext.Current is null. I still want to be able to access cache - it's in memory, so want to see if I can reference it somehow to save bits to disk.

Question - is there a way to reference cache in memory somehow when HttpContext.Current is null?

Perhaps I could create a global static variable that would store pointer to cache that I could update on HTTP requests (pseudo: "static <pointer X>" = HttpRequest.Current) and retrieve a reference to cache through that pointer in Application_End()?

Is there a better way to access Cache in memory when there is no Http Request is made?

Posted: Dec 15 10 at 8:25

View 3 Replies!   View Related
Access The HttpContext And Store Into A Local Variable?
I'm trying to access the HttpContextand store into a local variable (HttpContext ctx;) but am getting compile error, indicating I'm missing a directive. But I'm using the System.Web directive, which is the name space HttpContext is stored in.

Posted: Dec 12, 2009 03:29 PM

View 13 Replies!   View Related
Wcf - How To Access Authorization Web Service As A JavaScript File
A WCF web service with the right class and method attributes can be accessed as a JavaScript file in a script tag. That is:

<script type=".." src="http://someserver/someservice.wcs/js"></script>

Is it possible to do the same thing with System.Web.ApplicationServices.AuthenticationService?

I'm creating a PhoneGap application developed in static HTML/JavaScript, so I cannot use the script manager.

Posted: Jul 15 10 at 15:16

View 1 Replies!   View Related
C# - Using HttpContext.Current.CurrentHandler For Runtime View Access
Is there any potential pitfall for using HttpContext.Current.CurrentHandler for runtime view access?

public static GetView<T>(T view) where T : IView
{
return HttpContext.Current.CurrentHandler as T;
}

Posted: Feb 22 10 at 17:04

View 1 Replies!   View Related
Web Forms :: Adding OnFocus With GetGlobalResourceObject
I want to add an onFocus call to a server side textbox. I do not want to use the code behind if possible. The onFocus call will look something liek this

[Code]....

Obviously .NET will complain that this tag is not well formed. I know I could add it through the code behind, but I am trying to make this easier on designers.

Posted: Aug 19, 2009 02:46 PM

View 2 Replies!   View Related
Access A Javascript Which Resides In A Script File From Iframe?
i want to access a javascript function which resides in a script file from another page with iframe.
my sample code :

Page from which javascript need to be accessed.

<iframe id="FRAMESET" src="default.htm" width="0%" height="0%">
<p>
Your browser does not support iframes.
</p>
</iframe>
default.htm
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link href="Scripts/main.js" type="text/javascript" />
</head>
<body>
</body>
</html>
main.js
function helloWorld() {
alert("hello World");
}

i want to access this function on main page. i tried document.getElementById('FRAMESET').contentWindow.helloWorld(); but gave me error "that document.getElementById('FRAMESET').contentWindow.helloWorld();" is not a function.

Posted:

View 2 Replies!   View Related
MVC :: Access HTTPContext And Session From Custom Base Controller Class?
I built a base controller classinheritsfrom Controller class to add some custom behavior to all controllers which will inherit from this base class.

My issue is when I try to access HTTPContext and Session objects in my custom base class, they are always null.

Am I doing something wrong or need missing something?

My custom base class definition:

public class ApplicationControllerBase : Controller

controllers classes definition:

public class HomeController : ApplicationControllerBase

using ASP.NET MVC 1, .NET 3.5.

UPDATE:

It seems the issue is I try to access HTTPContext in the constructor while HTTPContext is not ready yet, I tried it in the OnActionExecuted event handler and it works fine.

My question is what is the best place to access Session object in my custom controller class, that will guarantee executing my code with all controllers.

Posted: Jan 13, 2010 03:12 PM

View 3 Replies!   View Related
C# - JavaScript PageMethods Call Loosing HttpContext.Current State?
I am using JavaScript's PageMethod functionality where I am invoking a PageMethod which works like a gem. However I am having an issue in accessing the HttpContext's state which returns me a value "SYSTEM" for

HttpContext.Current.User.Identity.Name

which is not the actual current User Name.

I know there are couple options like storing HttpContext.Current in a Session or saving Context's state in some other custom container but given a web farm environment I am assuming that this will not work as expected.

Here is the code I am working on with

function MyFunction(){
PageMethod.MyPageMethod();
}

here is the signature of the server method

[System.Web.Services.WebMethod()]
public static void MyPageMethod()
{
// gives me "SYSTEM"
var user = HttpContext.Current.User.Identity.Name;
}

Also if I use the above code to access user name in OnLoad event of the page then it works fine and returns me the CurrentUserName.

I am trying to get the above code to work in an ASP.NET Webform... :)

So I am wondering if there is a way to access the current actual user in page methods without making use of sessions.

Posted: Dec 29 10 at 23:24

View 1 Replies!   View Related
C# - Workaround For HttpContext.HideRequestResponse Being Internal? Detect If HttpContext.Request Is Really Available?
We're migrating an application to use IIS7 integrated mode. In library code that is designed to work either within the context of an HTTP request or not, we commonly have code like this:

if (HttpContext.Current != null &&
HttpContext.Current.Request != null) {
// do something with HttpContext.Current.Request
} else {
// do equivalent thing without HttpContext..
}

But in IIS7 integrated mode the check for HttpContext.Current.Request throws an exception whenever this code is called from Application_Start.

protected void Application_Start(object sender, EventArgs e)
{
SomeLibrary.DoSomethingWithHttpContextCurrentDetection();
}

Results in:

System.Web.HttpException: Request is not available in this context

How can I detect whether the request is really available without wrapping these calls in an exception handler and taking action based on whether an exception is generated or not.

Looking at HttpContext in Reflector I see it has an internal bool HideRequestResponse field but it's internal so I can only get to it with reflection and that's fragile. Is there a more official/approved way to determine if it's ok to call HttpContext.Request?

This blog post about the subject says not to use HttpContext, but how, in generic library code, can you determine if it's ok to use HttpContext?

http://mvolo.com/blogs/serverside/archive/2007/11/10/Integrated-mode-Request-is-not-available-in-this-context-in-Application_5F00_Start.aspx

I'm using the work-around mentioned there which is to use Application_BeginRequest and an initialized field to only initialize once as part of BeginRequest, but that has to be done in every calling application whereas I'd prefer to make the library code more robust and handle this situation regardless of where it's called from.

Posted: Apr 9 10 at 17:23

View 4 Replies!   View Related
C# - Retrieving Local Resource Values Correctly: GetGlobalResourceObject Or Control?
While developing I've seen a couple different ways to get local resources values from the resx files. Which one is considered the best practice?

Using the GetGlobalResourceObject method:

<a id="myLink" href="#"><%= GetGlobalResourceObject("Filter","Diary")%></a>

Or using a control and setting the value directly in the resx.

Posted: Oct 25 10 at 16:00

View 1 Replies!   View Related
AJAX :: Cross Domain Access Of Text File From Javascript Fails In Mozilla?
I have written code to accessa text file in another serverfrom my applicationin javascript. This code works fine inIE but fails inmozilla firefox. Below is the code i have written.

var httpRequest;
httpRequest = new XMLHttpRequest();
httpRequest.open('GET', url, true);
httpRequest.setRequestHeader('X-PINGOTHER','pingpong');
httpRequest.setRequestHeader('Content-Type','application/plain');
httpRequest.onreadystatechange = function() {alertContents(httpRequest);
httpRequest.send('');
function alertContents(httpRequest){
if (httpRequest.readystate == 4){
if (httpRequest.status == 200) {
alert(httpRequest.responseText);
}
}
}

Posted: Jan 05, 2010 01:16 AM

View 2 Replies!   View Related
Define A Function In Embeded Javascript File Of A Server Control To Access Page Load Event?
I have designded a asp.net server control that have an embeded javascript file.

document.getElementById("div_Messages_Back").style.left = 0;
document.getElementById("div_Messages_Back").style.top = 0;
document.getElementById("div_Messages_Back").style.width = document.documentElement.clientWidth;
document.getElementById("div_Messages_Back").style.height = document.documentElement.clientHeight;
document.getElementById("tbl_Messages").style.left = (document.documentElement.clientWidth - 250) / 2;
document.getElementById("tbl_Messages").style.top = (document.documentElement.clientHeight - 120) / 2;
function btn_Close() {
document.getElementById("div_Messages_Back").style.visibility = "collapse";
document.getElementById("tbl_Messages").style.visibility = "collapse";
}

I want the first 6 line of my javascript file run at runtime. But I recieve error at runtime:

Error: Object Required.

Posted: Jan 25 at 5:12

View 1 Replies!   View Related
C# - Determine The Physical Path Of A File Without An HttpContext?
I have some processes that run without an HttpContext in an ASP.NET MVC web application. This process needs to be able to determine the physical path to the Contents directory of the application for reading/writing data. But, since it is without an HttpContext, I don't get to use fancy things like Server.MapPath and such.

Posted: Aug 23 10 at 16:38

View 2 Replies!   View Related
SSL In HttpContext.Current.Response / Transmission File Protected By SSL?
In ASP.NET, if a file was downloaded on a page that was protected by SSL, through a server-side postback that writes to HttpContext.Current.Response.OutputStream, is the transmission that file ALSO protected by SSL?

Posted: Sep 21 10 at 0:28

View 1 Replies!   View Related
Web Forms :: How To Import Httpcontext.current Into VB Class File
From my code behind files I can set session variables just by typing something like:

session("whatever") = True

However, I have a VB class file called Engine.vb where I'm trying to do the same thing, but it's not working. To get it to work, I have to type something like:

HttpContext.Current.Session("whatever") = True

Is there a way that I can import all of HttpContext.Current so I don't have to type HttpContext.Current everytime. Why does this even happen here if it doesn't happen in the code behind files?

Posted: Apr 28, 2005 01:49 PM

View 3 Replies!   View Related
How To Use Httpcontext.response.transmitfile Or Other Function To Download A File From A Network?
Does anyone know how to use httpcontext.response.transmitfile or any other httpcontext function to download a file from a network drive instead of local drive? When I tried to use context.Response.TransmitFile(DownloadPath) to download files, the DownloadPath has to be local drive. If it's a network drive, the download failed.

Posted: Feb 25, 2010 01:55 PM

View 2 Replies!   View Related
State Management :: HttpContext.current.session Is Null In App_code/.cs File
1. SetSession.aspx page sets value for a session variable and redirects to default.aspx page using Response.redirect() code.

2. Default.aspx page tries to create an object of class in app_codecommon.cs file.

3. In app_codeCommon.cs file, I am trying to access the session variable set in step1 using HttpContext.Current.Session object.

but step 3 gives error that object reference not set to an instance. as HttpContext.Current.Session is null.

I surf abt it on net, and seems to be problem with asp.net framework.

Posted: May 20, 2010 07:25 AM

View 1 Replies!   View Related
C# - HttpContext.Current.Response Write File After Download Manager Starts?
I'm trying to create a ZIP file on the fly which might contain a few thousands of pictures.

[code]....

My question:

Is there a way to initiate the download (let the download manager on client side popup), and then start writing on the stream?

I monitored w3wp.exe (IIS) process, and it seems that the data is being written on memory instead of Stream.

When w3wp.exe memory usage riches a certain number, it releases the memory and nothing happens (no download).

Posted: Dec 17 10 at 20:54

View 2 Replies!   View Related
Web Forms :: How To Use Httpcontext.response.transmitfile Or Other Method To Download A File From A Network Drive
Does anyone know how to use httpcontext.response.transmitfile or any other httpcontext function to download a file from a network drive instead of local drive?

When I tried to use context.Response.TransmitFile(DownloadPath) to download files, the DownloadPath has to be local drive. If it's a network drive, the download failed.

Posted: Feb 25, 2010 01:53 PM

View 3 Replies!   View Related
Access The Current Thread's Context Using HttpContext.Current?
I have a static class with serveral static methods. In these methods, I'm trying to access the current thread's context using HttpContext.Current. For example:

var userName = HttpContext.Current.User.Identity.Name;

However, when I do that, I receive a NullReferenceException, the infamous "Object reference not set to an instance of an object."

Posted: Mar 11 10 at 2:12

View 3 Replies!   View Related
C# - Application_End() Cannot Access Cache Through HttpContext.Current.Cache
I want to be able to maintain certain objects between application restarts.

To do that, I want to write specific cached items out to disk in Global.asax Application_End() function and re-load them back on Application_Start().

I currently have a cache helper class, which uses the following method to return the cached value:

return HttpContext.Current.Cache[key];

Problem: during Application_End(), HttpContext.Current is null since there is no web request (it's an automated cleanup procedure) - therefore, I cannot access .Cache[] to retrieve any of the items to save to disk.

Question: how can I access the cache items during Application_End()?

Posted: Dec 12 10 at 1:37

View 4 Replies!   View Related
Relationship Between HttpContext.Request.Cookies And HttpContext.Response.Cookies
I have been experimenting with code that will clear all of the cookies in an HttpContext.Response.Initially, I used this:

DateTime cookieExpires = DateTime.Now.AddDays(-1);
for (int i = 0; i < HttpContext.Request.Cookies.Count; i++)
{
HttpContext.Response.Cookies.Add(
new HttpCookie(HttpContext.Request.Cookies[i].Name, null) { Expires = cookieExpires });
}

this will error with an OutOfMemoryException because the for loop never exits - each time you add a cookie to the Response, it also gets added to the `Request.

Posted: Nov 23 10 at 16:41

View 1 Replies!   View Related
Difference Between ControllerContext.HttpContext.Session And HttpContext.Current.Session
i'm using an example in which i can fake the session.It's for use in a unittest of a mvc controller.In the test i create a controller and then i do this:

FakeHttpContext httpctx = new FakeHttpContext(null,null,null,null,mSessionItems );
ControllerContext ctx2 = new ControllerContext(httpctx,new RouteData(), target);

here mSessionItems is my session and target is my instance of a controller,and indeed, when i'm in a controller reading this.ControllerContext.HttpContext.Session, i have a session, great!but.... i also read the session outside the controller, and there i use HttpContext.Current.Session, and that is null (or actualy, the HttpContext.Current is null).

Posted: Nov 23 10 at 14:36

View 1 Replies!   View Related
Subsequent Access To File. Error - The Process Cannot Access File It Is Being Used By Another
Isimply want tocreate one file and then delete it, means I want to access one file subsequently. Iam getting the very familiar error as shown in title. (Process can't access the file,) I have tried using file stream and all other stuff that I found from Googling but no success so far. Doesany body have small and neat solution? in short, I would like to run the following statements without any error.File.Create("C:\hsp1.txt");

File.Open("C:\hsp1.txt", FileMode.Open, FileAccess.Read, FileShare.None);

Posted: Mar 29, 2010 03:28 PM

View 2 Replies!   View Related
Access :: Creating An Excel File From Dataset Or Access File?
i have an asp.netapplication

c# code

i have adtabase in access and i craete adatset from it

i want to create excell file

Posted: Nov 21, 2010 06:15 AM

View 2 Replies!   View Related
Access :: Update Images Table In Microsoft Access DB Using File Uploader?
I have 4 file uploader in my form to upload 4 images in the DB for each article submitted. My issue when I want update/edit my article with some new pictures and I want delete or update the old pictures with the replacement with the new one.

How I can implement it? I am using ASP.NET based on VB.NOT .... NOT C#

Posted: Jan 06, 2011 01:03 PM

View 1 Replies!   View Related
Access :: Microsoft Office Access Database Engine Cannot Open Or Write To The File (.xls) Error?
Everything is working fine on client side. Now i just add my web application to IIS and after that when i am trying to browse the file

and getting the data from execl sheets. this error comes:

The Microsoft Office Access database engine cannot open or write to the file (.xls).

It is already opened exclusively by another user, or you need permission to view and write its data.but where should i have to give the permissions and all stuff. i tried everything, even i give all permission to IUSER, system, admin etc.

Here is what i an trying to do.User have to select the excel file from their computer by web application. when they click the button, all the data of that excel sheet shown up.

Posted: Dec 03, 2009 05:38 PM

View 1 Replies!   View Related
Access :: How To Create Data Access Layer Using Dataset.xsd File
Iam facing the problem with creating the Data Access layer using Dataset.xsd file and How to access the data from the file.

Posted: Feb 03, 2010 10:07 AM

View 2 Replies!   View Related
Access :: Save Unicode Chars In Access File?
I have to store unicode chars in my access database ( 2007) ( language : Gujarati). Is it required any special setting.... If can pass me link/ example

Posted: Nov 28, 2009 08:18 AM

View 1 Replies!   View Related
Access :: Upload An Excel File To Access Database
i would like to know hoew to upload an excel file to ms access database using c# in asp.net

Posted: Sep 24, 2009 04:56 PM

View 4 Replies!   View Related
Access :: Upload To Access DB / Restrict The File Type To .jpg?
i am building a member management sitefor a sports club, i have all the usual feilds

lastName, firstName,address1, address2, address3 ....

but they also want a photo

when i first made the DB i used access 2010 which uses the 2007 file type which supports attachments, however asp.net doesnt support the 2007 format. and the 2003 file type doesnt support attachments, i assume i use the OLE object data type but i have no idea how i get my aspx page "new.aspx" to upload an attachment. plus i want to restrict the file type to *.jpg

Posted: Apr 18, 2010 08:43 PM

View 1 Replies!   View Related
Access :: Back Up And Restore Ms Access File
i just wanted to know how to perform back up and restore of Ms Access database on a folder on the remote server through c# code.

Posted: Jun 06, 2010 04:57 PM

View 1 Replies!   View Related
"access Denied" When Access Server's COM Port Through Javascript
I've written a Generic Handler so I can access my server's COM port through javascript. I'm doing this, because I'm writing a Web Interface to an ESP-88 from BOSE, for internal use. The code must be configurable, and I added routines for both TCP/IP support and RS232. In a desktop app, the code runs fine, but in an ASP.net 4.0 App, the code crashes with the error "Access to the port 'COM2' is denied.". TCP/IP connections work, but serial is also required for us.

Posted: Aug 29 10 at 20:16

View 1 Replies!   View Related
How To Stop A JavaScript File From Downloading Twice In JavaScript
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?

Posted: Jan 27 at 19:04

View 1 Replies!   View Related
Web Forms :: Using A Javascript File For All The Javascript Functions?
I am using a javascript file for all the javascript functions........there I wrote all my validation functions.

I did not use a master page while starting the project but later I added a Master page and inherited it to all the screens.

When Master page was not added the javascript worked properly but then problem started as I inherited the master page. As I am passing parameters to the js file ,the value is shown as 'undefined' and its not working.

Posted: Sep 25, 2009 05:06 AM

View 8 Replies!   View Related
Access :: Write In (mdb) File. Adox Vb Code For Save Textboxs Data In Mdb File?
there are an access file . >> "test_file.mdb"

there are a table in mdb file .>> "test_table1"

and there are 2 columns in "test_table1" >> "name" and "age"

and i have 2 textbox in my web form . >> "textbox_name" and "textbox_age"

and i have a button for save textbox_name.text and textbox_age.text in mdb file .

i need adox vb code for save textboxs data in mdb file .

Posted: Dec 21, 2010 12:23 AM

View 4 Replies!   View Related
Web Forms :: Validate The Format Of The File Path In The File Upload Control Using Javascript?
Is it possible to validate the format ofthe file path in the file upload control using javascript??Is yes,pls give an example

Posted: Sep 11, 2009 09:17 AM

View 3 Replies!   View Related
Copyright 2005-08 www.BigResource.com, All rights reserved