How do I post and then redirect to an external URL from ASP_Net?
How do I post and then redirect to an external URL from ASP_Net? ASP_NET server-side controls postback to their own page. This makes cases where you want to redirect a user to an external page, but need to post to that page for some reason (for authentication, for instance) a pain. An HttpWebRequest works great if you don't want to redirect, and JavaScript is fine in some cases, but can get tricky if you really do need the server-side code to get the data together for the post. So how do you both post to an external URL and redirect the user to the result from your ASP_NET codebehind code? 6 Answers Here's how I solved this problem today. I started from this article on C# Corner, but found the example - while technically sound - a little incomplete. Everything he said was right, but I needed to hit a few external sites to piece this together to work exactly as I wanted. It didn't help that the user was not technically submitting a form at all; they were clicking a
Read more…
How to set up a CSS switcher
How to set up a CSS switcher I'm working on a website that will switch to a new style on a set date. The site's built-in semantic HTML and CSS, so the change should just require a CSS reference change. I'm working with a designer who will need to be able to see how it's looking, as well as a client who will need to be able to review content updates in the current look as well as design progress on the new look. I'm planning to use a magic querystring value and/or a javascript link in the footer which writes out a cookie to select the new CSS page. We're working in ASP_NET 3.5. Any recommendations? I should mention that we're using IE Conditional Comments for IE8, 7, and 6 support. I may create a function that does a replacement: <link href="Style/<% GetCssRoot() %>.css" rel="stylesheet" type="text/css" /> <!--[if lte IE 8]> <link type="text/css" href="Style/<% GetCssRoot() %>-i
Read more…
Wrapping lists into columns
Wrapping lists into columns I'm using ColdFusion to populate a template that includes HTML unordered lists ( <ul> s). Most of these aren't that long, but a few have ridiculously long lengths and could really stand to be in 2-3 columns. Is there an HTML, ColdFusion or perhaps JavaScript (I'm accepting jQuery solutions) way to do this easily? It's not worth some over-complicated heavyweight solution to save some scrolling. Is this jquery plugin of any use to you? Check out the Columnizer jQuery plugin. 13 Answers So I dug up this article from A List Apart CSS Swag: Multi-Column Lists. I ended up using the first solution, it's not the best but the others require either using complex HTML that can't be generated dynamically, or creating a lot of custom classes, which could be done but would require loads of in-line styling and possibly a huge page. Other solutions are still welcome though. It's sad that two years later there is still no clean w
Read more…
How do I keyboard up or down between drop-down options?
How do I keyboard down or up between drop-down "options"? I have a custom built ajax [div] based dynamic dropdown. I have an [input] box which; onkeyup , runs an Ajax search which returns results in div s and are drawn back in using innerHTML . These div s all have highlights onmouseover so, a typical successful search yields the following structure (pardon the semi-code): [input] [div id=results] //this gets overwritten contantly by my AJAX function [div id=result1 onmouseover=highlight onclick=input.value=result1] [div id=result2 onmouseover=highlight onclick=input.value=result2] [div id=result2 onmouseover=highlight onclick=input.value=result2] [/div] It works. However, I'm missing the important functions behind regular HTML elements. I can't keyboard down or up between "options". I know javascript handles keyboard events but; I haven't been able to find a good guide. (Of course, the follow-up question will end up being: can I use <
Read more…
Http Auth in a Firefox bookmarklet
Http Auth in a Firefox bookmarklet I'm trying to create a bookmarklet for posting del_icio_us bookmarks to a separate account. I tested it from the command line like: wget -O - --no-check-certificate \ "https_seconduser:thepassword@api_del_icio_us/v1/posts/add?url=http_seet_dk&description=test" This works great. I then wanted to create a bookmarklet in my firefox. I googled and found bits and pieces and ended up with: javascript:void( open('https_seconduser:password@api_del_icio_us/v1/posts/add?url=' +encodeURIComponent(location.href) +'&description='+encodeURIComponent(document.title), 'delicious','toolbar=no,width=500,height=250' ) ); But all that happens is that I get this from del_icio_us: <?xml version="1.0" standalone="yes"?> <result code="access denied" /> <!-- fe04_api_del_ac4_yahoo_net uncompressed/chunked Thu Aug 7 02:
Read more…
How can I turn a string of HTML into a DOM object in a FF extension?
How can I turn a string of HTML into a DOM object in a Firefox extension? I'm downloading a web page (tag soup HTML) with XMLHttpRequest and I want to take the output and turn it into a DOM object that I can then run XPATH queries on. How do I convert from a string into DOM object? It appears that the general solution is to create a hidden iframe and throw the contents of the string into that. There has been talk of updating DOMParser to support text/html but as of Firefox 3.0.1 you still get an NS_ERROR_NOT_IMPLEMENTED if you try. Is there any option besides using the hidden iframe trick? And if not, what is the best way to do the iframe trick so that your code works outside the context of any currently open tabs (so that closing tabs won't screw up the code, etc)? This is an example of why I'm looking for a solution other than the iframe hack, if I have to write all that code to have a robust solution, then I'd rather keep looking for something else. 5 Answers
Read more…
Call ASP . NET function from JavaScript?
Call ASP . NET function from JavaScript? I'm writing a web page in ASP . NET. I have some JavaScript code, and I have a submit button with a click event. Is it possible to call a method I created in ASP with JavaScript's click event? You should be using some Ajax library like : Anthem 20 Answers Well, if you don't want to do it using Ajax or any other way and just want a normal ASP . NET postback to happen, here is how you do it (without using any other libraries): It is a little tricky though... :) i. In your code file (assuming you are using C# and .NET 2.0 or later) add the following Interface to your Page class to make it look like public partial class Default : System.Web.UI.Page, IPostBackEventHandler{} ii. This should add (using Tab-Tab) this function to your code file: public void RaisePostBackEvent(string eventArgument) { } iii. In your onclick event in JavaScript, write the following code: var pageId = '<%= Page.ClientID %>'; __doPostB
Read more…
JavaScript Troubleshooting Tools in Internet Explorer
JavaScript Troubleshooting Tools in Internet Explorer I use Firebug and the Mozilla JS console heavily, but every now and then I run into an IE-only JavaScript bug, which is really hard to locate (ex: error on line 724, when the source HTML only has 200 lines). I would love to have a lightweight JS tool (a la firebug) for Internet Explorer, something I can install in seconds on a client's PC if I run into an error and then uninstall. Some Microsoft tools take some serious download and configuration time. Any ideas? Have you considered Firebug Lite? There is microsoft script debugger Use a tool which can be run as a bookmarklet: - Jash - Firebug Lite I think IE's F12 works pretty well 7 Answers You might find Firebug Lite useful for that. Its bookmarklet should be especially useful when debugging on a user's machine. Firebug no longer exists as a standalone entity; it has become part of Firefox dev tools. The link now redirects to their homepage which suggests u
Read more…