archive-gr.com » GR » D » DOTNETZONE.GR

Total: 987

Choose link from "Titles, links and description words view":

Or switch to "Titles and links view".
  • dotNETZone.gr
    Η ζώνη ώρας του τόπου του μέλους 2 GMT Τόπος Αθήνα Επάγγελμα Ενδιαφέροντα Γενέθλια Προσωπικός δικτυακός τόπος http dotnethints com Ιστολόγιο http dotnethints com Έκθεση Φωτογραφιών Υπογραφή Δημοσιεύσεων Υπογραφή http dotnethints com Σχετικά με Μπάδας Κώστας Λυπούμαστε δεν υπάρχει διαθέσιμο σύντομο βιογραφικό Στατιστικά στοιχεία αξιολόγηση και ιστορικό Πλήθος δημοσιεύσεων 22 Αξιολόγηση δημοσιεύσεων 128 Κοινόχρηστα Αγαπημένα Προτεινόμενα Μέλη Χαρακτηριστικό μέλους Δημοσιεύσεις Κατάταξη Δημοσιεύσεων Ενέργειες Αυτό το μέλος δεν έχει κοινόχρηστα προτεινόμενα

    Original URL path: http://www.dotnetzone.gr/cs/user/Profile.aspx?UserID=9454 (2015-07-15)
    Open archived version from archive


  • .NET Hints
    client sends a request to the server in order to get data In return the server will send the data back to the client We can also create requests using a few lines of code using the WebRequest class This is what this article is about To begin with we are going to create a simple GET requests to see how we can use it First we need to create a WebRequest object WebRequest request WebRequest Create http dotnethints com A request is by default a GET request If however we would like to change that we could use the request Method property Now we create the response WebResponse response request GetResponse So far so good Now we are going to get the page response That s what we wanted in the first place We will use a Stream and a StreamReader Stream dataStream response GetResponseStream StreamReader reader new StreamReader dataStream string responseFromServer reader ReadToEnd responseFromServer is the data we are looking for However we need to release the resources as soon as we are done reader Close dataStream Close response Close That s all Let s put it all together and create some C source code which gets the response from a page requested private string GetWebPageString string targetURL Create a request to the referenced URL WebRequest request WebRequest Create targetURL Get the response WebResponse response request GetResponse Create a Stream and StreamReader containing info from the server Stream dataStream response GetResponseStream StreamReader reader new StreamReader dataStream Get the info string responseFromServer reader ReadToEnd Release resources reader Close dataStream Close response Close return responseFromServer For example calling GetRequest http dotnethints com will return the dotnethints home page HTML This way we got our HTML info However this is usually not what we want to do Most likely we would prefer to get the part of the page which is of interest to us Supposing a web page contains the following div div id testDiv This is a test div div and what we want is to get the HTML contained within the testDiv div In that case we could use a method similar to the following private string HandleResponse string responseText string startString string endString string responseParts responseText Split new string startString StringSplitOptions None string handledResponse responseParts 1 Split new string endString StringSplitOptions None 0 We could use regular expressions instead string partPattern startString endString Match partMatch Regex Match responseText partPattern string handledResponse partMatch Groups 0 Value Remove 0 startString Length handledResponse handledResponse Remove handledResponse Length endString Length return handledResponse We could now get our the desired info using HandleResponse GetRequest http dotnethints com div id testDiv div and get the result we ve been expecting This is a test div So far we created a GET request In order to create a POST request we will first have to insert the POST parameters inside our HttpWebRequest object The following piece of code looks like the one we used in the previous GET request However we will need to set request s Method ContentType ContentLength and use a Stream object in order to send our parameters which we have enclosed within a byte array to the server private string GetWebPageStringPost string targetURL Create a request to the referenced URL WebRequest request WebRequest WebRequest Create targetURL Set request method request Method POST string formContent par1 1 par1 2 Set parameters to a byte array byte byteArray Encoding UTF8 GetBytes formContent Set content type and length request ContentType application x www form urlencoded request ContentLength byteArray Length Use a Stream to send parameters Stream dataStream request GetRequestStream dataStream Write byteArray 0 byteArray Length dataStream Close Get the response WebResponse response request GetResponse dataStream response GetResponseStream Create a StreamReader containing info from the server StreamReader reader new StreamReader dataStream Get the info string responseFromServer HttpUtility UrlDecode reader ReadToEnd Release resources reader Close dataStream Close response Close return responseFromServer A WebRequest example Before we go on let s take a look at an interesting example Supposing you want to create a dictionary and you are familiar enough with the Dictionary com so you know it is quite trustworthy a website Doing some research we find out that the search keyword is placed within the search url in the form of http dictionary reference com browse search keyword s t We also know that the primary result is always placed inside the following HTML code span class dnindex 1 span div class dndata search results div Using both facts mentioned we can create a simple method that gets a string parameter and returns the primary result This is our method private string UseOnlineDictionary string keyword return HandleResponse GetWebPageString http dictionary reference com browse keyword s t span class dnindex 1 span div class dndata div Using the following code Response Write dot UseOnlineDictionary dot Response Write br net UseOnlineDictionary net Response Write br hint UseOnlineDictionary hint we get dot a small roundish mark made with or as if with a pen net a bag or other contrivance of strong thread or cord worked into an open meshed fabric for catching fish birds or other animals a butterfly net hint an indirect covert or helpful suggestion clue Give me a hint as to his identity We have succeeded in creating a simple dictionary Well our dictionary will not be effective all the time as Dictionary com does not always create the HTML format we presumed it does For the sake of our example however we do not take all possible results and error handling into account Keep in mind that web pages are usually followed by privacy issues You may probably not be allowed to use directly or copy the content of a web page in case the author is not aware of it Thus the previous dictionary example no matter how simple or useful it may seem is not suggested to be of use none other than development practice Getting web pages info asynchronously We have already covered how to make asynchronous calls in a previous article If you are not familiar with asynchronous operations I d suggest you take a look before going any further Moving on let s do the previous dictionary example in a WPF manner GetStringAsync is a method contained within the HttpClient class It will cause an asynchronous request We are going to use the Result parameter to get the response HTML following our request All we need is a TextBox named KeywordTextBox a Label named ResultsLabel and a Button that calls the GetResultsButton Click method The user may insert his keyword in the KeywordTextBox and when the button is pressed he may get his results in the ResultsLabel This time however the request will be executed asynchronously While we wait for the response to get to us we may use that valuable time to compute other staff In just a few words when using asynchronous operations a method marked as async may use the await keyword to stop the code executing till all previous asynchronous methods are completed Here s the source code State the method as async so you can use the await keyword private void GetResultsButton Click object sender RoutedEventArgs e CreateAsyncRequest private async Task CreateAsyncRequest string keyword KeywordTextBox Text pageHTML will contain all page HTML string pageHTML await GetDictionaryAsync keyword Show results if pageHTML ResultsLabel Content HandleResponse pageHTML span class dnindex 1 span div class dndata div else In case sth goes wrong with the GetDictionaryAsync we get an empty string ResultsLabel Content Something went wrong Please try again private async Task string GetDictionaryAsync string keyword try HttpClient client new HttpClient Create asynchronous operation We are going to get the content of the dictionary web page asynchronously Task string getDotNetHintsStringTask client GetStringAsync http dictionary reference com browse keyword s t The method will still run at the same time as the asynchronous operation ComputeOtherStuff Here the method must wait for the response to complete await Task WhenAll getDotNetHintsStringTask return getDotNetHintsStringTask Result catch return private void ComputeOtherStuff ResultsLabel Content Getting data In the meanwhile several operations are executed Get the part of the page we are interested in private string HandleResponse string responseText string startString string endString string responseParts responseText Split new string startString StringSplitOptions None string handledResponse responseParts 1 Split new string endString StringSplitOptions None 0 return handledResponse This is the way the example works Summary WebRequest is a useful class that helps us create requests using Net code We can create both GET and POST requests and then get the response HTML using a stream object Using Net 4 5 we can create asynchronous requests so that we can continue working till the response is complete Reference DotNetHints Δημοσιεύτηκε στις Κυριακή 1 Ιουνίου 2014 9 38 μμ από το μέλος k badas 0 σχόλια Garbage collection and memory management Garbage collection is an essential part of Net architecture since it saves you from the trouble of managing the memory parts you have already used We are going to see what garbage collection actually is and what may cause it Next we ll check out how we can manage memory parts ourselves and talk about the disposed pattern Introduction Garbage collection was one of the first things I heard of when started learning Net Even so it s been some time since then that I got the first idea of what garbage collection is about as most developers were not interested in how it works Since garbage collection and memory allocation is not a part of a typical Net developer and it ain t broke it doesn t sound like it needs to be fixed However a developer who likes to know how things work may find this article quite interesting as it forms a simple description of what happens under the hood while our programs keep running The stack and the heap This is an older article where I talk about memory allocation in detail Let s just go through the basics and see how things are stored in memory so we can see how things are removed from memory later on A Net application gets a part of the available memory and uses it as its own This part is called virtual memory and even though it can be much larger in 64 bit systems than mere 4GB in 32 bit systems it will always be limited Information is stored in two parts of the virtual memory called the stack and the heap The stack stores value data types On the contrary the heap stores reference data types Supposing we wanted to create an integer value int int1 0 that value would be stored to the stack Now if we wanted to create a class object ReferenceTypeClass object1 new ReferenceTypeClass we would create a reference to the stack pointing to some certain point of the heap where we would store the actual object info Actually the heap consists of two types the small object heap and the large object heap Objects are by default stored in the small object heap unless they are larger than 85000 bytes in which case they are stored in the large object heap These types of heaps are no different to the garbage collector so we will refer to both in the same way heap Stack memory allocation So information is stored both on the stack and the heap Since the stack seems to be simpler than the stack let s do this first Stack values are stored the way a simple stack would From bottom to top However the stack can only take up to 1 MB of data Exceeding this limit will result in StackOverflow and I guess it is quite clear at that point why this exception is called that way To avoid this endless info flow Net uses a stack pointer This is nothing more than a simple pointer to the next available memory place So if I create some integer the stack pointer will rise by 4 bytes etc However when a variable stored in the stack goes out of scope the memory where it s value was stored is no longer useful and the stack pointer will fall down to the place where our integer was stored There it will wait till a new variable is created and overwrite the old integer s value That way the same memory parts will be used again and again thus causing the StackOverflow far less possible to be thrown A variable goes out of scope when it can no longer be used in our source code Here s an example bool getValueFromCookie GetValueFromCookie int unencryptedValue 0 if getValueFromCookie HttpCookie cookie Request Cookies EncryptedValue if cookie null int encryptedValue int cookie EncryptedValue unencryptedValue UnencryptInteger encryptedValue int newInteger 0 We have stored an encrypted integer within a cookie To get it back we check if getValueFromCookie is true and then we use UnencryptInteger to unencrypt the stored value This example contains three value types getValueFromCookie unencryptedValue and encryptedValue However the encryptedValue s scope extends far less than the other two variables This is because encryptedValue exists only within the if cookie null brackets When the code reaches the closing bracket the stack pointer will move to the point where the encryptedValue is stored in the stack The next command int newInteger 0 will cause this new variable to be placed on that position Heap memory allocation Garbage collection The heap also known as managed heap uses its own pointer the heap pointer In contrast to the stack the heap will keep moving the heap pointer to the next free memory part when a new object is created Using the same way as the stack to move the heap pointer up and down would be no good as due to the objects size diversity it wouldn t be easy for the heap pointer to find the position suitable to all new objects As a result the heap pointer always points to the next available memory part Repeating the same procedure for many objects the heap pointer would eventually reach the end of the heap In order to avoid this CLR will cause a garbage collection when the heap pointer surpasses an accepting threshold this threshold can be adjusted while the application runs Garbage collection will probably clear some part of the heap and allow the application to move on Here s how it works When an object gets out of scope its connection between the stack and the heap is lost much like it would happen if we had set that object to null When garbage collection is initialized it searches for objects whose connections are dropped We could also say that garbage collection searches for objects without roots Roots represent the location of the objects in the heap The memory these objects required is released When this procedure is completed the remaining parts are combined so that they form a solid part of the memory The heap pointer is then placed on top of that part waiting for the next object to be stored In the following image there are two examples of garbage collection In the first one object1 is set to null In the second it is object11 that is set to null Keep in mind you can initialize the garbage collection yourselves by calling System GC Collect However you are not advised to do so as the garbage collector and your application cannot both run at the same time So unless you are really sure there are many objects that need to be removed right now and not when CLR thinks it s time to do so you may chose to do so Generations Some interesting part concerning garbage collections is the way it separates older from younger objects The heap is separated into three sections called generations Generation 0 1 and 2 When an object is created it is placed into the generation 0 section The heap gets filled with objects this way until the generation 0 threshold is reached This is when garbage collection is initialized When the garbage collection is over all survival objects will be compacted and moved to the generation 1 section At the moment the generation 0 section is empty When the next garbage collection shows up the new remaining objects will be transferred to generation 1 section and all remaining objects formerly in generation 1 will be moved to generation 2 section The story goes on the same way Objects stored in generation 2 section surviving the garbage collection will simply be compacted in the same section until the time comes when they will be released Destroying objects Most people have heard that every class apart from the very popular constructor may have a destructor even though most of them haven t had the chance to use it A destructor is nothing more than a method named after Class Name This method can only be called automatically when an object is destroyed removed from the heap or the program terminates For example when an object is destroyed you may want to change some values in your class Behind the scenes a destructor will fire the Finalize method which is mostly used in languages like C That s why the destructors are also called finalizers by some developers Here s an example where we see a simple destructor in action protected void Page Load object sender EventArgs e TerminatingClass status UseGarbageCollector Show results ProgressLiteral Text TerminatingClass status private void UseGarbageCollector TerminatingClass t new TerminatingClass Set t to null so it does not survive garbage collection t null System GC Collect Wait for two seconds so the garbage collection is completed Thread Sleep 2000 class TerminatingClass IDisposable static public string status public TerminatingClass status Constructor TerminatingClass status Destructor We will use a string static variable to keep track of which methods are called First we create a TerminatingClass object Then it is set to null and we cause garbage collection If t was not null it would have survived the garbage collection Then we wait two seconds for the garbage collection to finish and the destructors to be called The result in our page is Constructor Destructor as expected Now here s a nice quote I ve heard concerning garbage collection Garbage collection is simulating a computer with an infinite amount of memory What this means is that even though your computer may have limited memory resources the fact that the garbage collection allows you to use the same resources again and again makes it seem like there s no end unless you get OutOfMemory or StackOverflow exceptions So what the garbage collection does is manage the memory when such a thing has to be done Supposing we had created a destructor expecting to work for some object of ours In case the amount of memory was large enough the garbage collector might never occur So presuming that garbage collection will always occur at least once is not accurate When an object whose class contains a destructor is created an instance is also created in the Finalize queue pointing that when this object is about to be removed from memory there are some things that need to be done first When such an object is about to be removed through garbage collection it is not instead due to the Finalize queue the destructor code will be executed Next time the garbage collection occurs is when that object will be removed Keeping that in mind we can tell that creating destructors may slow down the garbage collection Considering that a destructor cannot be called whenever you want among all that we have said you can see why destructors are not much used any more Instead most developers have turned to the disposed pattern Disposing of objects A class implementing the IDisposable interface must contain a Dispose method This method can either be used directly or by placing the object within a using statement Dispose is generally used to get rid of resources connected to an objected For example instead of writing SqlConnection con new SqlConnection connectionString con Close we could write SqlConnection con new SqlConnection connectionString con Dispose as SqlConnection s Dispose method will call the Close method itself using is a keyword which allows a reference variable to be used within but not outside the following brackets For example using SqlConnection con new SqlConnection do stuff Here s the catch Dispose will now be called when this object goes out of scope even if an exception occurs That way you avoid the try catch you would need before using con Close or con Dispose An example follows on similar to the previous showing how a dispose method works protected void Page Load object sender EventArgs e TerminatingClass status DisposeObject Show results ProgressLiteral Text TerminatingClass status private void DisposeObject using TerminatingClass t new TerminatingClass use t object to do stuff some object Dispose works as well TerminatingClass t new TerminatingClass t Dispose class TerminatingClass IDisposable static public string status public TerminatingClass status Constructor public void Dispose status Dispose Now the result is Constructor Dispose Destructors or Dispose A destructor is not the same as calling Dispose method A destructor will be called by garbage collector Dispose will be called either directly or when out of scope When an object is disposed it is not removed from memory Calling Dispose will do nothing more than calling dispose A combination of the previous methods TerminatingClass t new TerminatingClass t Dispose t null System GC Collect Wait for two seconds so the garbage collection is completed Thread Sleep 2000 will result in Constructor Dispose Destructor As said a disposed object is not removed from memory That is what the garbage collection looks after Using Dispose seems to be a better way to handle such issues than using destructors However you may choose to use both methods should you wish to cover all possible cases Summary Garbage collection is the way Net releases no more needed memory resources and is initialized when the CLR thinks it is needed We can create destructors containing code that will run when the object is about to be removed from memory Implementing the IDisposable interface classes may use the Dispose method to release resources much easier Reference DotNetHints Δημοσιεύτηκε στις Σάββατο 10 Μαΐου 2014 12 38 μμ από το μέλος k badas 1 σχόλια Strange little thing called postback I guess that most people know what postback is Well at least most developers that have been using ASP NET Web Forms If so you know that postback is an essential part of your application In this article we are going to search in depth what postback actually is how it is created and how it can be used in combination with other parts of web applications Brings back memories Probably the first time you heard of postback was when you tried to create a DropDownList the way it is in the following example asp DropDownList runat server ID DropDownListID asp Button runat server Text Click OnClick ButtonClicked asp Label runat server ID LabelID protected void Page Load object sender EventArgs e DropDownListID Items Add Element 1 DropDownListID Items Add Element 2 protected void ButtonClicked object sender EventArgs e LabelID Text Selected DropDownListID SelectedValue Feeling proud at how you managed to capture the DropDownList s value and print it you might have suddenly realized that your list contained two more elements than before Troubled you might have probably asked some senior developer in order to get an answer you should use the IsPostBack parameter if IsPostBack DropDownListID Items Add Element 1 DropDownListID Items Add Element 2 And suddenly it worked That s some magic here This may have been the first time you heard about postback You heard that the IsPostBack is a property that is always false the first time you request a page but is true when an event causes postback for example clicking a button Later on you found out that there are web controls like the DropDownList you had already seen which could be set events like OnSelectedIndexChanged so if a postback happened they would cause certain methods to occur There was an AutoPostBack parameter as well which could cause a postback of its own In that way whenever you picked a new element in the list you created a postback Later on you found out that there exists something called viewstate and that this viewstate carried along with it all the values your server controls contained This viewstate was sent back to the server when a postback request was created and this way the server could find out that you had either chosen Element 1 or Element 2 Because that value was automatically stored within the viewstate That was great Later on you heard people arguing that this great thing called viewstate was not so great after all as it could grow that big that could slow down the request and in total the response time Then people started disabling viewstate whenever they could do so and talking about ASP NET MVC and using pure JavaScript to create their requests No matter how this discussion ended about that time there may be a day when you look at yourself at the mirror and wonder What the heck is this postback that I ve been using for so long Even though only a few or none of the above may have occurred to you we are now ready to see what is actually happening during a postback Postback in action Let s create one more DropDownList control asp DropDownList runat server ID DropDownListID OnSelectedIndexChanged IndexChanged asp ListItem Text Item 1 Value 1 asp ListItem Text Item 2 Value 2 asp DropDownList This server control will be rendered into a simple select HTML code select name DropDownListID id DropDownListID option selected selected value 1 Item 1 option option value 2 Item 2 option select So far so good What we are actually interested in is the effect of the AutoPostBack parameter Let s add AutoPostBack true to the control The new HTML code consists of some interesting staff select name DropDownListID onchange BLOCKED SCRIPTsetTimeout 39 doPostBack 39 DropDownListID 39 39 39 39 0 id DropDownListID option selected selected value 1 Item 1 option option value 2 Item 2 option select First thing to notice is the presence of a JavaScript call onchange BLOCKED SCRIPTsetTimeout 39 doPostBack 39 DropDownListID 39 39 39 39 0 This command will call the doPostBack function If we perform some HTML decoding in the previous line we are calling doPostBack DropDownListID This doPostBack function is automatically inserted in the code by the ASP NET script type text javascript CDATA var theForm document forms form1 if theForm theForm document form1 function doPostBack eventTarget eventArgument if theForm onsubmit theForm onsubmit false theForm EVENTTARGET value eventTarget theForm EVENTARGUMENT value eventArgument theForm submit script And what it actually does is submitting the form having EVENTTARGET value equal to DropDownListID and EVENTARGUMENT value equal to in our case That s all concerning the client part Now the request is sent to the server To begin with keep in mind that a postback is always caused by a POST request However creating your own POST request code will not set IsPostBack to true Now let s see what the server will do next Request Form contains info sent to the server in case of a POST request It contains a lot of stuff such as viewstate Two interesting parts are EVENTTARGET and EVENTARGUMENT which we already saw while viewing client side You may be right to think that this info is transferred all the way to the server EVENTTARGET contains the ID of the control which caused the postback while EVENTARGUMENT contains the info it contains That s the way server knows which control caused the postback and is able find the proper method to call A postback will cause the event handlers specified to the control raised In the example the postback will call the IndexChanged method This method will be set to the page life cycle position saved for controls events That is after Page Load and before Page PreRender Let s see how we can use EVENTTARGET and EVENTARGUMENT to find out which control caused the postback or what the arguments are using if IsPostBack if String IsNullOrEmpty Request Form EVENTTARGET string ControlID Page Request Params EVENTTARGET Control postbackControl Page FindControl ControlID if Request Form EVENTARGUMENT null string argumentID Page Request Params EVENTARGUMENT Knowing which control caused the postback may sometimes save time from refreshing data in case you may not need to Something like the next piece of code could save a few seconds of your response time if IsPostBack Retrieve and compute data else if String IsNullOrEmpty Request Form EVENTTARGET if Page Request Params EVENTTARGET DropDownListID Retrieve and compute refreshed data else You do not need to refresh data Just use viewstate In the example EVENTARGUMENT is an empty string Other types of postback do not end up that way Intentionally we could call the doPostBack method ourselves and use the arguments we like Server controls such as Buttons may cause direct postbacks without JavaScript For example a button may be rendered as input type submit value Click me name ctl02 Such a postback would contain no values in EVENTTARGET or EVENTARGUMENT How do we know which control caused the postback then if EVENTTARGET is empty Remember our button asp Button runat server Text Click OnClick ButtonClicked If we clicked that the Request Form would contain something like this Button1 Click This is the way to go on In the previous method we should add if String IsNullOrEmpty Request Form EVENTTARGET string ControlID Page Request Params EVENTTARGET Control postbackControl Page FindControl ControlID else foreach string controlID in Request Form Check all possible info within the form Control objControl Page FindControl controlID if objControl is Button If it is a button this is what you are looking for string buttonControlID objControl ID break Finally keep in mind that you can create your own custom controls which can create and handle postbacks the way you want Avoid postback if possible Postback is usually great but it may sometimes cause trouble The faster a page responds the better a website feels Even though there may be hundreds of things you could do to speed up your website you should always keep in mind that excessive use of postbacks may backfire Postbacks allow you to have server side control over your page but that will cause a new request to be sent and a new response to wait upon That request will carry all the viewstate info along with it Let alone the fact that possible client JavaScript calls will be reset A postback is NOT user friendly therefore it should be used only when necessary That means when you need to do something which cannot be done client sided For example a redirect can be done using a Hyperlink server control or a button The Hyperlink will be rendered into an HTMLAnchor control and send a brand new request to the server asking for the new page and take it back On the contrast the button will cause a postback carrying the viewstate info along run through all the handlers till it reaches the button event handler and then redirect Even better we could straight away use an HTMLAnchor control In order to make a part of the page disappeardisapear we could use JavaScript or make a postback and set its visible parameter to false You should always go for the JavaScript whenever you can To change the data in your page you need not cause a postback Use AJAX instead Keep in mind that AJAX can t be the key to the solution all the time You should know when it is best to be used You may also try to reduce the total viewstate size if there are controls which do not need viewstate You can set their EnableViewState property to false EnableViewState is by default set to true Summary Postback is an ASP NET technique which helps us create a request carrying viewstate info back to the server in order to create a new response It uses client side JavaScript to submit the HTML form and will set the IsPostBack parameter to true We can use the submitted form to get info concerning the postback Even though postback may prove to be useful it should be avoided when possible as it may decrease our websites speed Reference DotNetHints Δημοσιεύτηκε στις Τετάρτη 16 Απριλίου 2014 11 58 μμ από το μέλος k badas 0 σχόλια Delegates Delegates are a way to handle methods in a different way than we are used to They comprise a basic part of the Net architecture and are important in order to use technologies like lambda expressions What is a delegate A delegate is a reference type which can be used as a connection between that and the methods it is assigned Think of it as a reference type for methods In a few words we can create the WriteSthDelegate delegate and the WriteSthMethod method Then we connect the method to the delegate Now we can use the delegate the way we would use the method Consider a delegate something like a pointer to a method Let s see an example We will use a simple literal object called DelegateOutputLitID to show the output Here s our delegate and the method it will use delegate void WriteSthDelegate string outputText void WriteSthMethod string outputText DelegateOutputLitID Text outputText and this is the way to associate them protected void Page Load object sender EventArgs e DelegateOutputLitID Text Attach WriteSthMethod while creating the writeSthDelegateObject delegate WriteSthDelegate writeSthDelegateObject new WriteSthDelegate WriteSthMethod writeSthDelegateObject Hello I am a delegate What do we have here We create an instance of the WriteSthDelegate and connect it to the WriteSthMethod From now on using the delegate in the way of writeSthDelegateObject Hello I am a delegate will be equal to calling the method WriteSthMethod Hello I am a delegate The output will be Hello I am a delegate Using a diagram this is the line followed in order to get the result Keep in mind that both the delegate and the method must have the same return value and the same arguments In our case the return value is void and there is one argument of string type In addition to using the method directly the connection between the delegate and the method can occur at runtime and we can thus create a much more flexible application Handling delegates We learned how to assign a method to a delegate Still a delegate can be assigned more than one method or dismiss some of the ones it is already assigned The way to do this is quite simple You associate the method you want to a new delegate object and then you either add the two delegates or subtract them much like you would do if you wanted to add or subtract two integers delegateObject newDelegateObject will assign new methods to a delegate delegateObject newDelegateObject will remove methods from a delegate s assigned list In order to combine two or more delegates they must be instances of the same delegate class You can also manage that by using the methods directly For example the previous commands will be the same as delegateObject newDelegateMethod delegateObject newDelegateMethod To create a useful example we will use one more method void WriteSthElseMethod string outputText DelegateOutputLitID Text br Hello outputText Now here s the example protected void Page Load object sender EventArgs e DelegateOutputLitID Text Attach WriteSthMethod while creating the writeSthDelegateObject delegate WriteSthDelegate writeSthDelegateObject new WriteSthDelegate WriteSthMethod writeSthDelegateObject Hello I am a delegate DelegateOutputLitID Text hr Attach WriteSthElseMethod to the writeSthDelegateObject delegate writeSthDelegateObject WriteSthElseMethod writeSthDelegateObject I am a delegate DelegateOutputLitID Text hr Remove WriteSthMethod from the writeSthDelegateObject delegate writeSthDelegateObject WriteSthMethod writeSthDelegateObject I am a delegate The output will be Hello I am a delegate I

    Original URL path: http://www.dotnetzone.gr/cs/blogs/kbadas/default.aspx (2015-07-15)
    Open archived version from archive

  • K# : Athens Global Azure Bootcamp Scheduled announced
    URL προαιρετικό Σχόλια απαιτούμενο Εισάγετε τον κωδικό Πρέπει να εισάγετε τον κωδικό επιβεβαίωσης Ο κωδικός επιβεβαίωσης δεν είναι σωστός παρακαλούμε προσπαθήστε ξανά Απομνημόνευση στοιχείων Search Go Το Ιστολόγιο Αρχική Σελίδα Ετικέτες NET 3 0 ADO NET Data Services ADO Net Entity Framework Architecture ASP NET Azure Azure Media Services C Caching Deepzoom DotNetZone Dynamic Data Enterprise Library Events General Net Great Sites IE8 Internet Explorer Linq Linq to SQL Metro Applications Microsoft Microsoft Azure Storage MS Application Blocks MVP Note to Self Off Topic Operating System Security Silverlight SQL Server TechEd TechEd 2008 TechEd 2009 TechEd 2010 TechEd 2013 Tools Uncategorized Utils I Like Vista Gadgets Visual Studio Web Windows 7 Windows 8 Windows Azure WP7 WPF Πλοήγηση Αρχική σελίδα Εκδηλώσεις Ιστολόγια Συζητήσεις Εκθέσεις Φωτογραφιών Αρχειοθήκες Ιστορικό Δημοσιεύσεων Απρίλιος 2015 2 Ιανουάριος 2015 1 Δεκέμβριος 2014 4 Νοέμβριος 2014 2 Οκτώβριος 2014 3 Ιούλιος 2014 1 Μάρτιος 2014 1 Φεβρουάριος 2014 1 Δεκέμβριος 2013 3 Ιούνιος 2013 2 Μάιος 2013 6 Απρίλιος 2013 1 Μάρτιος 2013 2 Ιανουάριος 2013 2 Δεκέμβριος 2012 5 Οκτώβριος 2012 1 Σεπτέμβριος 2012 1 Αύγουστος 2012 2 Ιούλιος 2012 6 Μάιος 2012 3 Απρίλιος 2012 1 Μάρτιος 2012 2 Φεβρουάριος 2012 1 Ιανουάριος 2012 1

    Original URL path: http://www.dotnetzone.gr/cs/blogs/kpantos/archive/2015/04/21/athens-global-azure-bootcamp-scheduled-announced.aspx (2015-07-15)
    Open archived version from archive

  • K#
    more Δημοσίευση στην κατηγορία Windows Azure Azure Storage Client Libraries and Tools September 2014 released 14 Οκτωβρίου 14 11 53 πμ spantos 0 σχόλια The Microsoft Azure Storage Team released their latest Azure Storage Client Libraries and Tools which Read more Δημοσίευση στην κατηγορία Windows Azure Microsoft Microsoft Azure Storage Azure Media Services Explorer Tool 10 Οκτωβρίου 14 01 14 πμ spantos 0 σχόλια Today the Azure Media Services team announced a new tool namely the Azure Media Services Read more Δημοσίευση στην κατηγορία Windows Azure Azure Media Services Free ebook Patterns Practices Cloud Design Patterns 07 Ιουλίου 14 10 55 πμ spantos 0 σχόλια Last month I had the opportunity to speak at a Microsoft event about best patterns Read more Δημοσίευση στην κατηγορία Events Windows Azure GWAB giveaways 26 Μαρτίου 14 12 20 πμ spantos 0 σχόλια With Global Windows Azure Bootcamp only a few days away I just received confirmation of Read more Δημοσίευση στην κατηγορία Events Windows Azure GWAB Registrations are now open 12 Φεβρουαρίου 14 10 54 πμ spantos 1 σχόλια Registrations for the Global Windows Azure bootcamp in Athens are now open Now is the Read more Δημοσίευση στην κατηγορία Events Windows Azure Global Bootcamp is comming to Greece Call for action 24 Δεκεμβρίου 13 12 35 πμ spantos 0 σχόλια In April of 2013 a bunch of MVPs held the first Global Windows Azure Bootcamp at Read more Δημοσίευση στην κατηγορία Uncategorized Another successfull ITPro DevConnections event 18 Δεκεμβρίου 13 05 41 μμ spantos 0 σχόλια It s been almost a month since this year s ITPro DevConnections and it s been at least a Read more Δημοσίευση στην κατηγορία Uncategorized Summernote Bootsrap rich editor 18 Δεκεμβρίου 13 03 06 μμ spantos 0 σχόλια Summernote is a simple clean and flexible WYSIWYG Editor that is built on top of jQuery Read more Δημοσίευση στην κατηγορία Note to Self Windows Azure Major Updates for Mobile Backend Development 14 Ιουνίου 13 01 59 μμ spantos 1 σχόλια It was only last week when I talked about Windows Azure mobile services in a Read more Δημοσίευση στην κατηγορία Windows Azure ITPro Dev Connections 2013 12 Ιουνίου 13 02 26 μμ spantos 0 σχόλια What an honor being part of this team running the largest Tech event in Greece Preparations Read more Δημοσίευση στην κατηγορία MVP Events Portable HttpClient is now available as RTM 30 Μαΐου 13 02 40 μμ spantos 0 σχόλια Microsoft Net Http was released today as a stable NuGet package Yep that s right You can finally Read more My Google Reader alternative using windows azure mobile services Part 3 25 Μαΐου 13 05 10 μμ spantos 0 σχόλια Now that my blogging engine is back on track it s time for the long awaited Read more Δημοσίευση στην κατηγορία Uncategorized Running WordPress with SQL Azure 18 Μαΐου 13 03 25 πμ spantos 0 σχόλια As you may have already read a couple of months back I migrated my blog Read more Δημοσίευση

    Original URL path: http://www.dotnetzone.gr/cs/blogs/kpantos/default.aspx (2015-07-15)
    Open archived version from archive

  • dotNETZone.gr
    gr Forum από το μέλος eliasm στις Μαΐου 20 2014 dotNETZone gr Community Event Θεσσαλονίκη reloaded Φίλες και φίλοι το dotNETZone gr σας προσκαλεί μετά από σχεδόν 3 χρόνια στην εκδήλωση που θα γίνει στις 25 Απριλίου 2014 στις 19 00 στο coho Ναπ Ζέρβα 10 54640 Θεσσαλονίκη www coho gr που μας παραχωρεί τον χώρο Tο θέμα της παρουσίασης που θα γίνει από τον Ηλία Μαρκέλη και την Λία Καμπάνταη θα είναι τα Universal apps Δημοσιεύτηκε στο Ειδήσεις του dotNETZone gr Forum από το μέλος eliasm στις Απριλίου 21 2014 Παρακολουθήστε δωρεάν το συνέδριο BUILD 2014 3 ημέρες online streaming Moscone Center San Francisco 2 4 Απριλίου 2014 buildwindows com Το συνέδριο Build είναι ο δρόμος που θα σας Δημοσιεύτηκε στο Ειδήσεις του dotNETZone gr Forum από το μέλος gcapnias στις Μαρτίου 31 2014 GWAB giveaways With Global Windows Azure Bootcamp only a few days away I just received confirmation of Read more Δημοσιεύτηκε στο K Weblog από το μέλος spantos στις Μαρτίου 26 2014 Gotcha OnLostMouseCapture always called by CaptureMouse at WPF It seems that CaptureMouse is behaving differently in WPF and Silverlight in that in the former one it immediately calls OnLostMouseCapture at a Visual whereas in Silverlight it doesn t get called if the element didn t have the mouse capture already btw in Silverlight that method is at a UIElement there is no Visual Δημοσιεύτηκε στο George Birbilis blog Weblog από το μέλος birbilis στις Μαρτίου 14 2014 TechEd Europe 2014 Βαρκελώνη 27 31 Οκτωβρίου 2014 Η Microsoft ανακοίνωσε πως η TechEd Europe θα γίνει την εβδομάδα 27 με 31 Οκτωβρίου 2014 στη Βαρκελώνη της Ισπανίας Οι εγγραφές για την εκδήλωση θα ξεκινήσουν την Άνοιξη σε ημερομηνία που θα ανακοινωθεί στο site της TechEd Europe http europe msteched com Η TechEd Europe είναι ένα από τα μεγαλύτερα συνέδρια της Microsoft για IT Δημοσιεύτηκε στο Ειδήσεις του dotNETZone gr Forum από το μέλος gcapnias στις Φεβρουαρίου 15 2014 GWAB Registrations are now open Registrations for the Global Windows Azure bootcamp in Athens are now open Now is the Read more Δημοσιεύτηκε στο K Weblog από το μέλος spantos στις Φεβρουαρίου 12 2014 Global Windows Azure Bootcamp Athens Σαβ 29 Μαρτίου Αγαπητοί φίλοι Τον Απρίλιο του 2013 πραγματοποιήθηκε το πρώτο Global Windows Azure Boot Camp με περισσότερες από 90 συμμετέχοντες χώρες Φέτος στις χώρες που θα συμμετάσχουν στο φετινό Boot Camp προστίθεται και η Ελλάδα Η κοινότητα Ελλήνων προγραμματιστών dotNETZone gr βρίσκεται στην ευχάριστη θέση να σας προσφέρει μια σε βάθος Δημοσιεύτηκε στο Ειδήσεις του dotNETZone gr Forum από το μέλος gcapnias στις Φεβρουαρίου 12 2014 GO Hackathon Το event των developers εγκαινιάζει η GLOBO Η GLOBO LSE AIM GBO πρωτοπόρος στους τομείς του Enterprise Mobility Management Mobile Application Development και επιχειρηματικού λογισμικού εγκαινιάζει το πρώτο GO Hackathon ένα event εκπαιδευτικού και διαγωνιστικού χαρακτήρα για developers που θέλουν να δημιουργήσουν το επόμενο viral ή best selling mobile app οι οποίοι σε ένα μαραθώνιο Δημοσιεύτηκε στο Ειδήσεις του dotNETZone gr Forum από το μέλος gcapnias στις Φεβρουαρίου 9

    Original URL path: http://www.dotnetzone.gr/cs/tags/Events/default.aspx (2015-07-15)
    Open archived version from archive

  • George Birbilis' blog : HowTo: Open page from Internet Explorer (Metro) app into desktop IE
    Spartan Apps Metro AmnesiaOfWho Desktop Σχόλια Χωρίς Σχόλια Έχει απενεργοποιηθεί η προσθήκη σχολίων από ανώνυμα μέλη About Μπιρμπίλης Γεώργιος Microsoft MVP J 2004 2010 Borland Spirit of Delphi 2001 http zoomicon com Search Go Το Ιστολόγιο Αρχική Σελίδα Επικοινωνία Ετικέτες NET Advertisement AmnesiaOfWho ASP net Audio Binding Blogs Browser Bugs C Class ClipFlair Collection Compatibility Compression Computers Computers and Internet Controls Design Downloads Ecology Editor Education e mail Errors E Slate Events Extensions Fail Filesystem Filters Fix Games Google Gotcha HowTo HTML HTML5 HTTP IE IE9 IE9RC IIS Installers Java Javascript Law Links MacOS X Media MediaElement Microsoft MMPPF Mouse None Plugins Posts Programming RegEx Replace Resources Samples Screenshot Scripts Search Security Selection Server Sharing Silverlight SMF Smooth Streaming Source String Suggestions Text Transforms Troubleshooting Twitter UI URL Usability Video Vista Visualization VisualStudio Web Windows Windows 7 Windows 8 WinForms Word WordPress Workarround WPF XAML YouTube ZIP ZUI Αταξινόμητα Πλοήγηση Αρχική σελίδα Εκδηλώσεις Ιστολόγια Συζητήσεις Εκθέσεις Φωτογραφιών Αρχειοθήκες Ιστορικό Δημοσιεύσεων Ιούνιος 2015 3 Μάιος 2015 1 Απρίλιος 2015 2 Μάρτιος 2015 2 Φεβρουάριος 2015 1 Ιανουάριος 2015 2 Δεκέμβριος 2014 3 Νοέμβριος 2014 3 Οκτώβριος 2014 1 Σεπτέμβριος 2014 2 Αύγουστος 2014 6 Ιούλιος 2014 1 Μάιος 2014 1 Απρίλιος 2014 2 Μάρτιος 2014 3 Φεβρουάριος 2014 2 Δεκέμβριος 2013 2 Νοέμβριος 2013 2 Σεπτέμβριος 2013 2 Αύγουστος 2013 3 Ιούλιος 2013 5 Ιούνιος 2013 2 Μάιος 2013 3 Απρίλιος 2013 2 Μάρτιος 2013 2 Φεβρουάριος 2013 4 Δεκέμβριος 2012 6 Νοέμβριος 2012 11 Οκτώβριος 2012 5 Σεπτέμβριος 2012 2 Αύγουστος 2012 9 Ιούλιος 2012 11 Ιούνιος 2012 8 Μάιος 2012 2 Απρίλιος 2012 2 Φεβρουάριος 2012 5 Ιανουάριος 2012 5 Δεκέμβριος 2011 8 Νοέμβριος 2011 3 Οκτώβριος 2011 4 Σεπτέμβριος 2011 8 Ιούλιος 2011 3 Ιούνιος 2011 2 Μάιος 2011 2 Μάρτιος 2011 4 Φεβρουάριος 2011 8 Ιανουάριος 2011

    Original URL path: http://www.dotnetzone.gr/cs/blogs/birbilis/archive/2015/04/20/howto-open-page-from-internet-explorer-metro-app-into-desktop-ie.aspx (2015-07-15)
    Open archived version from archive

  • dotNETZone.gr
    Apps RSS AmnesiaOfWho Browser Desktop HowTo IE11 Internet Explorer Metro Plugins Posts Silverlight Spartan Windows 8 Workarround HowTo Open page from Internet Explorer Metro app into desktop IE The Windows 8 8 1 app version of Internet Explorer is also known as IE Metro because of the Metro codename inspired by navigation signs in public transport of the Modern UI design language promoted by Microsoft However that version isn t

    Original URL path: http://www.dotnetzone.gr/cs/tags/Apps/default.aspx (2015-07-15)
    Open archived version from archive

  • dotNETZone.gr
    Desktop RSS AmnesiaOfWho Apps Browser HowTo IE11 Internet Explorer Metro Plugins Posts Silverlight Spartan Windows 8 Workarround HowTo Open page from Internet Explorer Metro app into desktop IE The Windows 8 8 1 app version of Internet Explorer is also known as IE Metro because of the Metro codename inspired by navigation signs in public transport of the Modern UI design language promoted by Microsoft However that version isn t

    Original URL path: http://www.dotnetzone.gr/cs/tags/Desktop/default.aspx (2015-07-15)
    Open archived version from archive



  •