Google Search

Google
 

Tuesday, May 27, 2008

Video: How Do I: Learn the Tips and Tricks of Experts?

Presenter:Scott Stanfield

View tips and tricks including encrypting sensitive information stored in the web.config file, posting content to a different page, simplifying complex URLs using URL remapping, and much, much more.


Click here to go to original video page

The following text is a software generated transcript of the video. Click on a minute link to jump to a location within the video

Minute 0

Were and that no of tips and tricks without missing a great place to showcase a lot of miscellaneous features around his peanut to point out that we found were very useful during the Christmas video what you need a place to fit the features that fit in the other videos to start with a new website we do all the videos will call this tricks and the one of the greatest features that we have here is something that I purchased a lot time with working around Eesti net 1 1 and that is encrypting sections in your web config if you recall if he seem to get a video with config the connection settings areas where we store the connection information for a database now frequently you might have a username and password in here and it s kind of the Achilles heel because you have to store the password information clear text bothers a really easy way to encrypt the information and decrypt it I ll show you how that works right now so we ll start by first creating on yet
Minute 1

Pages for this piece so credit a web form for little use the protected section of the web config and let s see we need we need some data to work with are we have a connection to a separate machine that has a database installed on a soft rag customers table over and by doing this of the data grid and also a SQL data adapter now for switch to the web config file the suit of the connection string was added automatically here but look at the connection string it s not a regular start using integrated authentication it s using the old SQL Server style with a with the userid and password so we would like disinformation to be encrypted so select the page and remove some columns would still need to see all of this cat that s good okay to buttons the first button
Minute 2

Will enable the encryption on the on that section of the web config encrypt them a second button will turn it off like this would clear fillets and the handlers for both button cells to it quickly by double clicking on both and I m to bring in some code I have sitting around here in this notepad to copy this and pasted and I ll explain it showed the first chunk of code goes here the top this import namespace command because reusing some features on a system web config and then we have a function called a cryptic config that takes a Boolean true or false will call that I think the first button enables encryption and cryptic config true and encrypt config faults remotely explain the code so the path the relative path to
Minute 3

A web config file is located here often and oversight I used the Web configuration manager to open it up out of local config file because you can have his work and take the different layers different levels of your site somewhat one of the top level would get the connection setting in the connection string section from the config file and either encrypted using protect section or decrypted using unprotect section and finally to save it so it s just a little simple piece of code rather sobering as Opera browser okay we see that works just fine right now and just to doublecheck the web config section here s not encrypted by hit school than the very bottom in his encrypt a page refresh the code runs in a switchback here sure enough as is the file to modify and there is encrypted to go back and hit refresh the page to query still works just fine and I can hit clear text to send it back to normal
Minute 4

Succeeds this is a little bit code to do that now you have to execute that code every machine that can run this but it s very handy trick to know about accident and other handy trick noticed that I scroll down to bottom each time watch this if I go to protect aspx at the top poet Tom maintain scroll position on post back and said that equal to true and ago here at the bottom encrypted again ago try clear text notice now it s keeping it at the bottom so it s keeping is remembering the scroll position one at these buttons even though the page is refreshing very simple something that s very frustrating to have to implement the plan or its move onto the next tip I don t need these two areas anymore will do talk about the cold cross page posting
Minute 5

And for that I need to pages page 1 and page 2 page 2 and on the first page we want to have a simple form and will do will take the contents of this text box and whatever we select in this calendar control and pass those two values to as another page page to now normally you have to do this trick using took a session variable so the button click would be handled inside page 1 you d stick the two values of text box in the calendar into a session verbal and in the response of redirector server transfer over to page too cumbersome and doesn t really make it easy to work with what we have to do instead is as good the button and find a post back URL and math that to page 2 aspx and I think it sucks that we had to do for this page we say that the good page to
Minute 6

This is the page we want to will spit something backout show you what you typed in and that label and finally will distract page 1 here to have a hyperlink to get back so in the source code for this common at a form page load method so will execute this body of code if the page is not in the post back state and will set the label one text equal to see through the province who want to set the sequel to data coming from the other page so also the string format is to make a clean all say hello to zero you clicked on one and here s where we need to reference the controls from the previous page and just as you would expect there is a nurse and auctioneer for previous page a defined control I want the text box 1 edit it as an know what it s returning text box 1 has in fact we do this as codes can get with a complicated
Minute 7

Let s put it right here so we know the text box 1 is a text box are pretty variable tea as text box and else said it equal to the return value of previous page but I need a cast that to a text box to do that I use the type and put all that sunny text box okay same idea for the calendar control all said that equal to control the previous page on control calendar calendar one and cast it to counter not sure if this is case sensitive but I ll put the tea like that okay now I have access to tease text value and the selected value for the calendar which pleases the selected date associates as works off before I continue
Minute 8

Another trick to show you I wanted to start typing right now but notice that the big precursors not sentenced Xbox and I m guessing the enter key is not mapped to this button there is a quick thing you can do to fix that this is new to ASP net to point out and set the form tag you can now set a default button and a default Xbox and it will set the focus for you if I scroll to the form default button is about one and a control as the default focus is text box 1 much better looks brings up the browser not to start typing right away without sin hit enter to go straight to the page you can spot probably should select something again in January 31 Scott there so you can see we do the cross page posting and that we re able to enable some thing I really like that s the default the
Minute 9

And default focus and so they bring a default aspx will do the rest of our work here the first thing we ll show you see this demo wall will be about using the bulleted list control of disc of the little bottles of header section or Sophie looked at here with a single bulleted list and this is new I can tied directly to a couple of items I just adhere let s face a list of hyperlinks so the text could be Microsoft and how have the value be Microsoft com and for now just have one entry in there if we go to properties for that control I can have it interpret the value items as hyperlink and that is under display mode will make them hyperlinks shaves the browser you can see it is changed to an underline and egotistical to Microsoft com and click on it but even more interesting is I can
Minute 10

Like a lot of the other controls bind it to a data source so well do I could list of hyperlinks to create an XML file will call at hyperlinks so very quickly I ll show you could live the features of the XML editor reaching its pretty easy associate is to create come to a link on the fly so a first or first link will be called on Microsoft and the URL is Microsoft com and I ll do a link for MSDN can finally want for ASP net
Minute 11

Coconuts goods will go back to our goal to lose control and bind it to a data source to create a new data source choose XML file to force it to monitor things like a database for any arbitrary object will go to the XML file and choose hyperlinks now that this little wizard smart enough to expect it and see what what options I have all choose to buy the text to the text item and this to the URL and hit save and we have to bring it up here in order to see it and we have these three that s pretty heady few you if you re using both a blistering a list of hyperlinks works great effect its move to the and XP Sims can use little HTML HR tags just a separate article to little demos now talk about the file upload control if you need to
Minute 12

The means to upload files to your site that s pretty easy on first you drag the file upload control and here you get the browse button and a text box with user would want Tom go browse to the local path in their computer for file I need a button to actually do the upload itself to change the text to upload and then I ll have a server side hyperlink which all set to point to the resultant file that s been uploaded to say that we create a folder here missile this folder will hold the files of the upload upload it to upload okay first way to make sure that the actually at the end user should put a file to be uploaded and interested at the upload button so if the file upload one control has a file to be uploaded and will execute this code we want to tell the upload control the glad to say that file to have the
Minute 13

Is off the local folder here and you get a very good a local path seeks upload with the file name of the file path that will tend that the file upload one filename him in the Vatican couple times the actual file name and were told to go to bed to save it and it will set our hyperlink text equal to the name the file and set the hyperlink and navigate URL equal to a float and in the file that will be good to have their doubts I have a file on my desktop and I can upload them to bring it up perfect to develop load is really easy to use and you should probably do some scrubbing on the following path is coming and you probably need a lockdown the folder but more Bush would show you pretty
Minute 14

Get a file name and start the upload process in the next be so one show you his article URL mapping is really handy if you have a file on your system or in your website has a really obscure your elder son that s complicated and you want to give a a simpler name or more human readable name and I have in Haiti coup would write here ready to go to demonstrate us what say you had an HTML file called good_and it s a crazy long name in this works with HTML or ASP net or any any page really so I have a really long name here and to better keep that gal just belong in here and it s it simply starts fine but I thought one have a hyperlink to that on my site I would know which dragged over but you have a pretty long name instead let s say I want to have a hyperlink of simpler now put one equal to just do it HTML this page is actually exist on a
Minute 15

Bite but that s okay because in the web config we can use the URL mapping to point to that file for the web config_Web internal URL mappings need to enable it true okay to add an entry for the URL to make your relative to our site to a htm and then been mapped URL is equal to the really long ugly looking name will say that go back to our page and give the hyperlink shot so that one should work for this is the one or testing to a htm and it works well endorsed a page that simply but believe me it does work so that is difficult that is the URL mapping the final piece will show you
Minute 16

Is a new control called multiview multiuser is quite interesting to very easy way for you to have a up a body of content linked imaginative tags that you can show and hide dynamically speaking to a program I click that I come and take these three little demos and make them all selectable and saddest multiview and the way it works is a course through subtracting a dropping original to view on the page and I need a view component for each one of these three sections of us are first one view on will contain all bolt bulleted list demo tag view to getting to write their U2 will have a file upload them all in view three will contain the URL mapping demo this clinic is a charged with a good body away from your programmatic way to
Minute 17

Jews which view is active at any time sofa that I ll use a radio button list just drop them right there and have it automatically post backs we get the change event s dominant code these by hand store with three of them are first one is neat bulleted list and I may give it a value of zero to one second list item 1 is the file upload and the final one is URL mapping has a value to an ace at the steps of horizontal to vertical can of the code is executed when you change that is selected index changed so drop it to the handler for that which is empty so let s do this so we have a multiview one of the active view index that s that it can be 01 or two as with reviews said that equal to
Minute 18

Radio button radio button list one to its selected index Russians like the value of the same thing so just want a code we can switch between the views they re so let s say that you bring up the browser which is bulleted list file upload URL mapping for the great way if you have a lot of code or local law of what is on your page you need to hide or few need to be able to dynamically shown high pieces of the good way to do it such attention tricks video hope you enjoyed it and get the chance to look at some the other videos I think the final lot more I m hidden features that we didn t specifically call out but there s a lot here and hope you have a good chance use of these techniques in your next site

No comments: