Daily Archives

Articles indexed Wednesday April 21 2010

Page 28/126 | < Previous Page | 24 25 26 27 28 29 30 31 32 33 34 35  | Next Page >

  • Escape Quote in C# for javascript consumption

    - by Jason
    I have a ASP.Net web handler that returns results of a query in JSON format public static String dt2JSON(DataTable dt) { String s = "{\"rows\":["; if (dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { s += "{"; for (int i = 0; i < dr.Table.Columns.Count; i++) { s += "\"" + dr.Table.Columns[i].ToString() + "\":\"" + dr[i].ToString() + "\","; } s = s.Remove(s.Length - 1, 1); s += "},"; } s = s.Remove(s.Length - 1, 1); } s += "]}"; return s; } The problem is that sometimes the data returned has quotes in it and I would need to javascript-escape these so that it can be properly created into a js object. I need a way to find quotes in my data (quotes aren't there every time) and place a "/" character in front of them. Example response text (wrong): {"rows":[{"id":"ABC123","length":"5""}, {"id":"DEF456","length":"1.35""}, {"id":"HIJ789","length":"36.25""}]} I would need to escape the " so my response should be: {"rows":[{"id":"ABC123","length":"5\""}, {"id":"DEF456","length":"1.35\""}, {"id":"HIJ789","length":"36.25\""}]} Also, I'm pretty new to C# (coding in general really) so if something else in my code looks silly let me know.

    Read the article

  • How to remove thie ".svc" extension in RESTful WCF service?

    - by Morgan Cheng
    In my knowledge, the RESTful WCF still has ".svc" in its URL. For example, if the service interface is like [OperationContract] [WebGet(UriTemplate = "/Value/{value}")] string GetDataStr(string value); The access URI is like "http://machinename/Service.svc/Value/2". In my understanding, part of REST advantage is that it can hide the implementation details. A RESTful URI like "http://machinename/Service/value/2" can be implemented by any RESTful framework, but a "http://machinename/Service.svc/value/2" exposes its implementation is WCF. How can I remove this ".svc" host in the access URI?

    Read the article

  • Pop up box in Ruby on Rails

    - by palani
    Hi I want to display a popup windo on my rails application... Here is exactly what i want is . I have the line called "My profile" (for link i used link_to). if user clicks the link the popup should come out and displays the user's profile details.... i tried with :popup = 'true' option but it creates new window. i want some Ajax kind of stuff... can any one help me on this.

    Read the article

  • Installing Mercurial on Windows Apache XAMPP Tutorial

    - by Tim Dellas
    After asking this question (http://stackoverflow.com/questions/2675764/xampp-mercurial-installation-on-windows-apache-hgwebdir-cgi-script-error) and reading though the whole internet including this question (http://stackoverflow.com/questions/644322/how-do-i-get-mercurials-hgwebdir-working-on-windows) and all its links for about 10 hours, I seem to not be able to find a solution. I begun with this tutorial http://mercurial.selenic.com/wiki/HgWebDirStepByStep ... and I really don't want to install ancient versions of Mercurial. I got my windows-apache to run Python scripts, CGI-Scripts, publish them in the wild, but hgwebdir just won't work. Question 1: Can someone please enrich his personal blog with a tutorial on how to install MERCURIAL on a WINDOWS XAMPP installation and make it visible to the world? I guarantee a lot of pageviews, as this is not a trivial problem. And this would sincerely help a lot of other people I guess. Question 2: For example, even after browsing half a day through everywhere, I just cannot find out, which version of python I need to pair with the freshest version of mercurial, and I get the "magic number is wrong"-error. This would be my question, if noone has time to make up a nice blogpost. Sorry for being a bit frustrated.

    Read the article

  • Apache - Tomcat ProxyPass VirtualHost - Context Path

    - by Arne
    Hi, I have a problem configuring apache tomcat ProxyPass directive for two applications that have two different Contaxt Pathes in tomcat. The tomcat is running behind an apache and I use the apache to proxy path the requests to tomcat. In apache I want to access both application via a hostname instead of a context path. Scenario: tomcat https://domain:8443/app1 https://domain:8443/app2 in tomcat the applications have the context path app1 and app2 in apache I want to enable both application as follow: https://app1.host/ https://app2.host/ In apache I have created a configuration for each domain: ProxyPass / https://localhost:8443/app1 ProxyPassReverse / https://localhost:/8443/app1 The strange thing is app1 is only available through apache using the context path: https://app1.host/app1 Is it possible to realize such a setup with apache ProxyPass module? Thx for your help.

    Read the article

  • Sum of every N lines ; awk

    - by Sharat Chandra
    I have a file containing data in a single column .. I have to find the sum of every 4 lines and print the sum That is, I have to compute sum of values from 0-3rd line sum of line 4 to 7,sum of lines 8 to 11 and so on .....

    Read the article

  • How to get the running of time of my program with gettimeofday()

    - by Mechko
    So I get the time at the beginning of the code, run it, and then get the time. struct timeval begin, end; gettimeofday(&begin, NULL); //code to time gettimeofday(&end, NULL); //get the total number of ms that the code took: unsigned int t = end.tv_usec - begin.tv_usec; Now I want to print it out in the form "**code took 0.007 seconds to run" or something similar. So two problems: 1) t seems to contain a value of the order 6000, and I KNOW the code didn't take 6 seconds to run. 2) How can I convert t to a double, given that it's an unsigned int? Or is there an easier way to print the output the way I wanted to?

    Read the article

  • Using RSYNC to Replicate Synology NAS DS710+ to Windows 7 Hard Drive

    Learn how to use a local backup drive on your windows 7 system to replicate the data on any or all of your directories on your Synology NAS (Network Hard Drive Device) DS710+.  This post will... This site is a resource for asp.net web programming. It has examples by Peter Kellner of techniques for high performance programming...Did you know that DotNetSlackers also publishes .net articles written by top known .net Authors? We already have over 80 articles in several categories including Silverlight. Take a look: here.

    Read the article

  • How do I search only my tweets in Twitter?

    - by terrani
    I am new to Twitter. Rather than using twitter to broadcast my text, I would like to organize my ideas using hashtags. One thing I can't figure out is that I can't search my tweets ONLY. How do I limit search result so I can only see my tweets? I tried from:myid #test, it does not work.

    Read the article

  • Visual Studio 2010 Language Support

    - by inspectorG4dget
    Hello SO, I want to be able to develop code using Visual Studio 2010. I just got VS2010 and I'm not able to get the languages I want on it. The main reason that I'm asking this is that I'm trying to migrate to ONE IDE that does it all for me. Thus far eclipse has been doing a good job, but I've been informed that VS2010 is better and I'm trying to get into the groove of that standard So my question is two-fold. I am not able to find a complete list of languages supported by VS2010. What are these languages? How can I get VS2010 support for: a. Python/IronPython b. C/C++/C#/XNA c. Java My Googling has given me no promising/definitive results. I'd really appreciate any help.

    Read the article

  • Replacing IFrame with div

    - by Roland
    I have a IFrame where I load in a custom search, and display the results within the iframe. The search results I obtain by calling an external url, that returns a value. I need to implement the same thing for a mobi site that works on mobile devices, and thus I need to replace the IFrame with something else. Will this be possible using a div tag, since most mobile devices do not support frames. And no javascript may be used. Any advice will be appreciated.

    Read the article

  • How can I do geographic traffic redirection and setup an edge server

    - by don
    Hi, Ours is a webbased software as a service application. Our data centers are located on the west coast, and we would like to provide better user experience to our East coast clients. How can I setup an edge server on the east coast, and serve static data like images and javascript from there, but still refer to west coast server for application logic. -Don

    Read the article

  • Testing ASP.NET webservice using NUnit and transferring session state

    - by herbertyeung
    I have a NUnit test class that starts an ASP.NET web service (using Microsoft.VisualStudio.WebHost.Server) which runs on http://localhost:1070 The problem I am having is that I want to create a session state within the NUnit test that is accessible by the ASP.NET web service on localhost:1070. I have done the following, and the session state can be created successfully inside the NUnit Test, but is lost when the web service is invoked: //Create a new HttpContext for NUnit Testing based on: //http://blogs.imeta.co.uk/jallderidge/archive/2008/10/19/456.aspx HttpContext.Current = new HttpContext( new HttpRequest("", "http://localhost:1070/", ""), new HttpResponse( new System.IO.StringWriter())); //Create a new HttpContext.Current for NUnit Testing System.Web.SessionState.SessionStateUtility.AddHttpSessionStateToContext( HttpContext.Current, new HttpSessionStateContainer("", new SessionStateItemCollection(), new HttpStaticObjectsCollection(), 20000, true, HttpCookieMode.UseCookies, SessionStateMode.Off, false)); HttpContext.Current.Session["UserName"] = "testUserName"; testwebService.testMethod(); I want to be able to get the session state created in the NUnit test for Session["UserName"] in the ASP.NET web service: [WebMethod(EnableSession=true)] public int testMethod() { string user; if(Session["UserName"] != null) { user = (string)Session["UserName"]; //Do some processing of the user return 1; } else return 0; } The web.config file has the following configuration for the session state configuration and would like to remain using InProc than rather StateServer Or SQLServer: <sessionState mode="InProc" stateConnectionString="tcpip=127.0.0.1:42424" cookieless="false" timeout="20"/>

    Read the article

  • What is a read only collection in C#?

    - by acidzombie24
    I ran a security code analyst i found myself having a CA2105 warning. I looked at the grade tampering example. I didnt realize you can assign int[] to a readonly int. I thought readonly was like the C++ const and makes it illegal. The How to Fix Violations suggest i clone the object (which i dont want to do) or 'Replace the array with a strongly typed collection that cannot be changed'. I clicked the link and see 'ArrayList' and adding each element one by one and it doesnt look like you can prevent something adding more. So when i have this piece of code what is the easiest or best way to make it a read only collection? public static readonly string[] example = { "a", "b", "sfsdg", "sdgfhf", "erfdgf", "last one"};

    Read the article

  • how to save class object in registry?

    - by younevertell
    Basically I have some class objects, each with three properties. Once one class object is selected in the ComboBox, the corresponding properties shows on three textboxs. I am trying to add one save button. I can change the value of the properties. Once the save button is clicked, all the class ojects with three corresponding properties are saved in the registry. Save setting for later use It seems Registing tryKey.SetValue Method can not save an object directly?

    Read the article

  • Changing keyboard layout on application focus

    - by Anonymous Coward
    Hi Everyone As everybody knows the en-US Keyboard-layout is the best one for programming. So I'd like to use it in my IDEs. But since I live in a non-en-US country I need the de-CH layout for all other applications. Now I wonder if it is possible to set the layout depending to which application currently has the focus. If that is possible, can a human brain adapt to such a behaviour or is it just confusing? cheers, AC

    Read the article

  • The same property and procedure in different Classes. How they can be accessed ?

    - by lyborko
    Hi, I created several new objects TMyMemo = class (TMemo) private FYahoo = Integer; procedure SetYahoo(Value:integer) public procedure Google(A,B:integer; S:string); published property Yahoo:integer read FYahoo write SetYahoo; end; TMyPaintbox = class (TPaintbox) private FYahoo = Integer; procedure SetYahoo(Value:integer) public procedure Google(A,B:integer; S:string); published property Yahoo:integer read FYahoo write SetYahoo; end; TMyButton = class (TButton) private FYahoo = Integer; procedure SetYahoo(Value:integer) public procedure Google(A,B:integer; S:string); published property Yahoo:integer read FYahoo write SetYahoo; end; . . . These Controls are placed on Form1. Is there a way, how can I change the same property (Yahoo) and run the procedure (Google), which is declared in different objects (inheritance is not possible) ? procedure Form1.Button1Click(Sender:TObject); var i:integer; begin for i:=0 to Form1.ControlCount-1 do begin Controls[i].Google(4,5, 'Web'); // this should be changed somehow Controls[i].Yahoo:=6; // this should be changed somehow end; end; end; Thanks

    Read the article

  • Java Refreshing a screen

    - by Goutham
    I have a screen in which one of its components is made invisible depending on a boolean value. If the boolean changes after the screen has been created, how do I refresh the screen to take this into account?

    Read the article

< Previous Page | 24 25 26 27 28 29 30 31 32 33 34 35  | Next Page >