Daily Archives

Articles indexed Wednesday March 17 2010

Page 5/128 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • How to generate XML with attributes in c#.

    - by user292815
    I have that code: ... request data = new request(); data.username = formNick; xml = data.Serialize(); ... [System.Serializable] public class request { public string username; public string password; static XmlSerializer serializer = new XmlSerializer(typeof(request)); public string Serialize() { StringBuilder builder = new StringBuilder(); XmlWriterSettings settings = new XmlWriterSettings(); settings.OmitXmlDeclaration = true; settings.Encoding = Encoding.UTF8; serializer.Serialize( System.Xml.XmlWriter.Create(builder, settings ), this); return builder.ToString(); } public static request Deserialize(string serializedData) { return serializer.Deserialize(new StringReader(serializedData)) as request; } } I want to add attributes to some nodes and create some sub-nodes. Also how to parse xml like that: <answer> <player id="2"> <coordinate axis="x"></coordinate> <coordinate axis="y"></coordinate> <coordinate axis="z"></coordinate> <action name="nothing"></action> </player> <player id="3"> <coordinate axis="x"></coordinate> <coordinate axis="y"></coordinate> <coordinate axis="z"></coordinate> <action name="boom"> <1>1</1> <2>2</2> </action> </player> </answer> p.s. it is not a xml file, it's answer from http server.

    Read the article

  • flash blocking javascript events

    - by jedierikb
    this is an edit of the original post now that I better understand the problem. now with source code! In IE, if body (or another html div has focus), then you keypress & click on flash at the same time, then release... a keyup event is never fired. It is not fired in javascript or in flash. Where is this keyup event? This is the order of event firing you get instead: javascriptKeyEvent:bodyDn ** currentFocuedElement: body javascriptKeyEvent:docDn ** currentFocuedElement: body actionScriptEvent::activate ** currentFocuedElement: [object] actionScriptEvent::mouseDown ** currentFocuedElement: [object] actionScriptEvent::mouseUp ** currentFocuedElement: [object] Subsequent keyup and keydown events are captured by flash, but that initial keyUp is never fired.. anywhere. And I need that keyup! Here is the html/javascript: <html> <head> <script type="text/javascript" src="p.js"></script> <script type="text/javascript" src="swfobject.js"></script> <script> function ic( evt ) { Event.observe( $("f1"), 'keyup', onKeyHandler.bindAsEventListener( this, "f1Up" ) ); Event.observe( $("f2"), 'keyup', onKeyHandler.bindAsEventListener( this, "f2Up" ) ); Event.observe( document, 'keyup', onKeyHandler.bindAsEventListener( this, "docUp" ) ); Event.observe( $("body"), 'keyup', onKeyHandler.bindAsEventListener( this, "bodyUp" ) ); Event.observe( window, 'keyup', onKeyHandler.bindAsEventListener( this, "windowUp" ) ); Event.observe( $("f1"), 'keydown', onKeyHandler.bindAsEventListener( this, "f1Dn" ) ); Event.observe( $("f2"), 'keydown', onKeyHandler.bindAsEventListener( this, "f2Dn" ) ); Event.observe( document, 'keydown', onKeyHandler.bindAsEventListener( this, "docDn" ) ); Event.observe( $("body"), 'keydown', onKeyHandler.bindAsEventListener( this, "bodyDn" ) ); Event.observe( window, 'keydown', onKeyHandler.bindAsEventListener( this, "windowDn" ) ); Event.observe( "clr", "mousedown", clearHandler.bindAsEventListener( this ) ); swfobject.embedSWF( "tmp.swf", "f2", "100%", "20px", "9.0.0.0", null, {}, {}, {} ); } function clearHandler( evt ) { clear( ); } function clear( ) { $("log").innerHTML = ""; } function onKeyHandler( evt, dn ) { logIt( "javascriptKeyEvent:"+dn ); } function AS2JS( wha ) { logIt( "actionScriptEvent::" + wha ); } function logIt( k ) { var id = document.activeElement; if (id.identify) { id = id.identify(); } $("log").innerHTML = k + " ** focuedElement: " + id + "<br>" + $("log").innerHTML; } Event.observe( window, 'load', ic.bindAsEventListener(this) ); </script> </head> <body id="body"> <div id="f1"><div id="f2" style="width:100%;height:20px; position:absolute; bottom:0px;"></div></div> <div id="clr" style="color:blue;">clear</div> <div id="log" style="overflow:auto;height:200px;width:500px;"></div> </body> </html> Here is the as3 code: package { import flash.display.Sprite; import flash.display.StageAlign; import flash.display.StageScaleMode; import flash.events.KeyboardEvent; import flash.events.MouseEvent; import flash.events.Event; import flash.external.ExternalInterface; public class tmpa extends Sprite { public function tmpa( ):void { extInt("flashInit"); stage.align = StageAlign.TOP_LEFT; stage.scaleMode = StageScaleMode.NO_SCALE; stage.addEventListener( KeyboardEvent.KEY_DOWN, keyDnCb, false, 0, true ); stage.addEventListener( KeyboardEvent.KEY_UP, keyUpCb, false, 0, true ); stage.addEventListener( MouseEvent.MOUSE_DOWN, mDownCb, false, 0, true ); stage.addEventListener( MouseEvent.MOUSE_UP, mUpCb, false, 0, true ); addEventListener( Event.ACTIVATE, activateCb, false, 0, true ); addEventListener( Event.DEACTIVATE, dectivateCb, false, 0, true ); } private function activateCb( evt:Event ):void { extInt("activate"); } private function dectivateCb( evt:Event ):void { extInt("deactivate"); } private function mDownCb( evt:MouseEvent ):void { extInt("mouseDown"); } private function mUpCb( evt:MouseEvent ):void { extInt("mouseUp"); } private function keyDnCb( evt:KeyboardEvent ):void { extInt( "keyDn" ); } private function keyUpCb( evt:KeyboardEvent ):void { extInt( "keyUp" ); } private function extInt( wha:String ):void { try { ExternalInterface.call( "AS2JS", wha ); } catch (ex:Error) { trace('ex: ' + ex); } } } }

    Read the article

  • Advanced donut caching: using dynamically loaded controls

    - by DigiMortal
    Yesterday I solved one caching problem with local community portal. I enabled output cache on SharePoint Server 2007 to make site faster. Although caching works fine I needed to do some additional work because there are some controls that show different content to different users. In this example I will show you how to use “donut caching” with user controls – powerful way to drive some content around cache. About donut caching Donut caching means that although you are caching your content you have some holes in it so you can still affect the output that goes to user. By example you can cache front page on your site and still show welcome message that contains correct user name. To get better idea about donut caching I suggest you to read ScottGu posting Tip/Trick: Implement "Donut Caching" with the ASP.NET 2.0 Output Cache Substitution Feature. Basically donut caching uses ASP.NET substitution control. In output this control is replaced by string you return from static method bound to substitution control. Again, take a look at ScottGu blog posting I referred above. Problem If you look at Scott’s example it is pretty plain and easy by its output. All it does is it writes out current user name as string. Here are examples of my login area for anonymous and authenticated users:    It is clear that outputting mark-up for these views as string is pretty lame to implement in code at string level. Every little change in design will end up with new version of controls library because some parts of design “live” there. Solution: using user controls I worked out easy solution to my problem. I used cache substitution and user controls together. I have three user controls: LogInControl – this is the proxy control that checks which “real” control to load. AnonymousLogInControl – template and logic for anonymous users login area. AuthenticatedLogInControl – template and logic for authenticated users login area. This is the control we render for each user separately because it contains user name and user profile fill percent. Anonymous control is not very interesting because it is only about keeping mark-up in separate file. Interesting parts are LogInControl and AuthenticatedLogInControl. Creating proxy control The first thing was to create control that has substitution area where “real” control is loaded. This proxy control should also be available to decide which control to load. The definition of control is very primitive. <%@ Control EnableViewState="false" Inherits="MyPortal.Profiles.LogInControl" %> <asp:Substitution runat="server" MethodName="ShowLogInBox" /> But code is a little bit tricky. Based on current user instance we decide which login control to load. Then we create page instance and load our control through it. When control is loaded we will call DataBind() method. In this method we evaluate all fields in loaded control (it was best choice as Load and other events will not be fired). Take a look at the code. public static string ShowLogInBox(HttpContext context) {     var user = SPContext.Current.Web.CurrentUser;     string controlName;       if (user != null)         controlName = "AuthenticatedLogInControl.ascx";     else         controlName = "AnonymousLogInControl.ascx";       var path = "~/_controltemplates/" + controlName;     var output = new StringBuilder(10000);       using(var page = new Page())     using(var ctl = page.LoadControl(path))     using(var writer = new StringWriter(output))     using(var htmlWriter = new HtmlTextWriter(writer))     {         ctl.DataBind();         ctl.RenderControl(htmlWriter);     }     return output.ToString(); } When control is bound to data we ask to render it its contents to StringBuilder. Now we have the output of control as string and we can return it from our method. Of course, notice how correct I am with resources disposing. :) The method that returns contents for substitution control is static method that has no connection with control instance because hen page is read from cache there are no instances of controls available. Conclusion As you saw it was not very hard to use donut caching with user controls. Instead of writing mark-up of controls to static method that is bound to substitution control we can still use our user controls.

    Read the article

  • Microsoft <3 jQuery

    - by Latest Microsoft Blogs
      Today at Mix10 we announced our increased support and involvement in the jQuery Library and how we are working closely with the community and the jQuery Team to accelerate the development of this already powerful front-end library. In recent weeks Read More......(read more)

    Read the article

  • LDAP Authentication for multiple AD Domains

    - by TrevJen
    I have 3 full trust domains (2 child and one root). I need to use LDAP to allow authntication for domain users. The trick is that I need the application to use an AD server for the child domain BUT proxy the LDAP query and authentication for the root domain. I see that it maty be possible with AD LDS and some trusts and synching, but it looks pretty hairy and overly complicated. The short of it is: 3 domains (Parent, ChildA, ChildB) My 3rd party app will need to use ChildA domain servers to authenticate either: a. a user in the parent domain or b. a user in the ChildB domain I already have full trusts between all domains, and regular NTLM authentication works fine (unless you are trying to authenticate with LDAP)

    Read the article

  • path problem with mod_rewrite, XDebug, PDT, XAMPP and Windows XP

    - by Delirium tremens
    My mod_rewrite turns accounts/create into index.php?folder=accounts&action=create, but pdt ignores it, so when I try to start a PHP Script debug session, I have to type a folder location in the file field and pdt doesn't accept. When PDT auto generates the URL for the PHP Web Page debug session, I go to http://localhost/myframe/index.php?XDEBUG%5FSESSION%5FSTART=ECLIPSE%5FDBGP&KEY=12569067976875, but myframe is in the frameworks folder, so I get a 404 error. When I check a breakpoint, uncheck Auto Generate, add frameworks before myframe in URL, set Start Debug from http://localhost/frameworks/myframe/accounts/create in Advanced and click Debug, the debugger doesn't stop at the breakpoint.

    Read the article

  • Toshiba Satellite Touchpad not working correctly in Windows 7

    - by BoundforPNG
    I have a P305-S882 Satellite laptop that I have installed Windows 7 on. I went to the web site and downloaded the drivers available for Windows 7 but It still does not work correctly. The left mouse key does not always work like it should. I tried loading the Synaptic Touchpad driver for Vista but it still does not work correctly. Any ideas?

    Read the article

  • creating TAGS for Ruby and emacs

    - by hortitude
    I ran the following from my top level Ruby on Rails directory find . -name "*.rb" | etags - Then within emacs I visited that tag file. This works reasonably well to find some of the methods and most of the files, however it is having trouble finding some of the extra methods/classes that I use in my helpers directory. e.g. I have a file in my helpers dir called my_foo_helper.rb If I search my tags for that file, it finds it. However, if I try to find a tag for one of the methods within that module it doesn't find it at all. If I use Aptana or something like that it seems to be able to locate those methods. Any thoughts? Thanks!

    Read the article

  • Unable to set variables in bash script in Mac OSX

    - by cohortq
    Hello! I am attempting to automate moving files from a folder to a new folder automatically every night using a bash script run from applescript on a schedule. I am attempting to write a bash script on Mac OSX, and it keeps failing. In short this is what I have (all my ECHOs are for error checking): !/bin/bash folder = "ABC" useracct = 'test' day = date "+%d" month = date "+%B" year = date "+%Y" folderToBeMoved = "/users/$useracct/Documents/Archive/Primetime.eyetv" newfoldername = "/Volumes/Media/Network/$folder/$month$day$year" ECHO "Network is $network" $network ECHO "day is $day" ECHO "Month is $month" ECHO "YEAR is $year" ECHO "source is $folderToBeMoved" ECHO "dest is $newfoldername" mkdir $newfoldername cp -R $folderToBeMoved $newfoldername if [-f $newfoldername/Primetime.eyetv]; then rm $folderToBeMoved; fi Now my first problem is that I cannot set variables at all. Even literal ones where I just make it equal some literal. All my echos come out blank. I cannot grab the day, month, or year either,it comes out blank as well. I get an error saying that -f is not found. I get an error saying there is an unexpected end of file. I made the file and did a chmod u+x scriptname.sh I'm not sure why nothing is working at all. I am very new to this bash script on OSX, and only have experience with windows vbscript. Any help would be great, thanks!

    Read the article

  • Do I need to auto-login after account activation?

    - by Art
    This is the standard scenario: User registers on the site User receives an account activation email, clicks link to activate Web site notifies the user that account is activated Now there are at least two pathways: User is taken to the login screen and asked to enter login details User is automatically logged in and taken to a welcome/profile/etc page While there are obvious benefits in (1) as far as the user's experience is concerned, there could be drawbacks as well. Option (2) offers improved security at cost of UX. Which of the scenarios is preferable and why? Any serious flaws in any of them?

    Read the article

  • Client-Side script to upload attachments to the Sharepoint 2007 list

    - by Clone of Anton Makrushin
    Hello. I have no good script-writing experience. So, I have a list created on MOSS 2007 with about 1000 elements and attachments enabled. I need to attach to each list item file (*.jpg) from a local folder. I doesn't have administrator privileges at MOSS server, only contributor rights Here is my script: $web = new-Object system.Net.WebClient $web.Credentials = [System.Net.CredentialCache]::DefaultCredentials $web.Headers.Add("user-agent", "PowerShell Script") $web.UploadFile('http://ruglbsrvsps/IT/Lists/Test1/', 'C:\temp\Attachments\14\Img1.jpg' ) Test1 - target list; Item1, Item2, Item3 - list items, without attachments, created manually When I run script, it returns byte array and does not upload file to the list item. Can you fix my script or advice better solution for my task (attach bulk of files to the MOSS list items, only contributor rights for target Sharepoint 2007 list) Thank you.

    Read the article

  • How do you set a custom session when unit testing with wicket?

    - by vagabond
    I'm trying to run some unit tests on a wicket page that only allows access after you've logged in. In my JUnit test I cannot start the page or render it without setting the session. How do you set the session? I'm having problems finding any documentation on how to do this. WicketTester tester = new WicketTester(new MyApp()); ((MyCustomSession)tester.getWicketSession()).setItem(MyFactory.getItem("abc")); //Fails to start below, no session seems to be set tester.startPage(General.class); tester.assertRenderedPage(General.class);

    Read the article

  • Binding files in C#?

    - by ravedome
    Hey, Is it possible to bind two files into one file ? If its possible how ? E.g if i got two files a.exe and b.exe then i want to bind them into c.exe so when i execute c.exe it'll automatically execute a.exe and b.exe Thank

    Read the article

  • How to str_replace a section of PHP Code

    - by whatshakin
    $embedCode = <<<EOF getApplicationContent('video','player',array('id' => $iFileId, 'user' => $this->iViewer, 'password' => clear_xss($_COOKIE['memberPassword'])),true) EOF; $name = str_replace($embedCode,"test",$content); I'm trying to replace a section of code with another piece of code. I can do it with smaller strings but once I added the larger strings to $embedCode, it throw an "unexpected T_ENCAPSED_AND_WHITESPACE" error

    Read the article

  • Why my Google endpoint is always the same?

    - by joetsuihk
    always: https://www.google.com/accounts/o8/ud i got wordpress openid ok. so i think is is just discovery phase got some probelms.. <?php $ch = curl_init(); $url = 'https://www.google.com/accounts/o8/id'; $url = $url.'?'; $url = $url.'openid.mode=checkid_setup'; $url = $url.'&openid.ns=http://specs.openid.net/auth/2.0'; $url = $url.'&openid.claimed_id=http://specs.openid.net/auth/2.0/identifier_select'; $url = $url.'&openid.identity=http://specs.openid.net/auth/2.0/identifier_select'; $url = $url.'&openid.return_to='.site_url().'/user/openid/login_callback'; $url = $url.'&openid.realm=http://www.example.com/'; // set url curl_setopt($ch, CURLOPT_URL, $url); //return the transfer as a string curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HTTPHEADER,array("Accept: */*")); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); // $output contains the output string $xdr = curl_exec($ch); if (!$xdr) { die(curl_error($ch)); } // close curl resource to free up system resources curl_close($ch); $xml = new SimpleXMLElement($xdr); $url = $xml->XRD->Service->URI; $request = $connection->begin($url); $request always null...

    Read the article

  • Amazon S3 and swfaddress

    - by justinbach
    I recently migrated a large AS3 site (lots of swfs, lots of flvs) to Amazon S3. Pretty much everything but HTML and JS files is being stored/served from Amazon, and it's working well. The only problem I'm having is that I built the site using SWFaddress (actually, via the Gaia framework which uses SWFaddress), and for some reason, SWFaddress is no longer updating the address bar correctly as users navigate from page to page. In other words, the URL persistently remains http://www.mysite.com, not http://www.mysite.com/#/section as would be the case were SWFaddress functioning correctly (and as it was functioning prior to the migration). Stranger yet, if I go to (e.g.) http://www.mysite.com/#/section directly, the deeplinking functions as you'd expect--I arrive directly at the correct section. However, navigating away from that section doesn't have any effect on the address bar, despite the fact that it should be dynamically updated. I've got a crossdomain.xml file set up on the site that allows access from all domains, so that's not the issue, and I don't know what else might be. Any ideas would be greatly appreciated! P.S. I integrated S3 by putting pretty much the entire site in an S3 bucket and then just changing the initial swfobject embed to point to the S3 instance of main.swf, passing in the S3 path as the "base" param to the embedded swf so that all dynamically loaded assets and swfs would also be sourced from s3. Dunno if that's related to the troubles I'm having.

    Read the article

  • Creating a Web Wrapper for COM and OCX

    - by balexandre
    Hi guys, Today we have a windows application that, using an OCX, creates a web page (visible by a WebBrowser control in a small .NET WinForm application) and communicates through COM to the main application/client. (not relevant but this is Pascal) I'm currently responsible to re create this application in a web environment so we can have the same functionality shared through Web as the user can see the same in a Web Browser. The Windows application has almost 4 years on it and I need to re create everything from scratch, and all the bugs/features find in the future in the Windows Application I have to re create them again in the Web... Ohh well, you can see where this will end. I was thinking... is there any way I can create a Wrapper, even using 3rd party commercial objects, to: Communicate with the COM Object Can expose the content of the OCX (this in my most confortable language, ASP.NET C#, but other are welcome) I was thinking out loud, can this be accomplish with a Java Applet? Any ideas or any point to the right road will be appreciated.

    Read the article

  • My New BDD Style

    - by Liam McLennan
    I have made a change to my code-based BDD style. I start with a scenario such as: Pre-Editing * Given I am a book editor * And some chapters are locked and some are not * When I view the list of chapters for editing * Then I should see some chapters are editable and are not locked * And I should see some chapters are not editable and are locked and I implement it using a modified SpecUnit base class as: [Concern("Chapter Editing")] public class when_pre_editing_a_chapter : BaseSpec { private User i; // other context variables protected override void Given() { i_am_a_book_editor(); some_chapters_are_locked_and_some_are_not(); } protected override void Do() { i_view_the_list_of_chapters_for_editing(); } private void i_am_a_book_editor() { i = new UserBuilder().WithUsername("me").WithRole(UserRole.BookEditor).Build(); } private void some_chapters_are_locked_and_some_are_not() { } private void i_view_the_list_of_chapters_for_editing() { } [Observation] public void should_see_some_chapters_are_editable_and_are_not_locked() { } [Observation] public void should_see_some_chapters_are_not_editable_and_are_locked() { } } and the output from the specunit report tool is: Chapter Editing specifications    1 context, 2 specifications Chapter Editing, when pre editing a chapter    2 specifications should see some chapters are editable and are not locked should see some chapters are not editable and are locked The intent is to provide a clear mapping from story –> scenarios –> bdd tests.

    Read the article

  • What PHP configuration and extensions are recommended for speed, efficiency and security?

    - by Sanoj
    I am setting up an Ubuntu server with nginx and PHP. I have read about many different configurations and extensions that could be added and it is pretty hard to know about all of them. I would like to hear from you, sysadmins, what PHP configuration and extensions do you recommend? I have read about: Suhosin for security Alternative PHP Cache for speed and efficiency Memcache for speed and efficiency PHP FastCGI Process Manager for speed and efficiency But I have no idea if they are good or not, and if I should use them together.

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >