Technical

/Technical

Properties – the basics

By |2018-06-19T13:12:15+00:00March 4th, 2017|Categories: Technical|Tags: , |

Properties in C# is a special type of methods called accessors, they are accessed as if they are public member fields but with read, write and compute the value. Is is declared like a field but with a get and set blocks inside, get is to read the property value and must return the same property type, set is to write to the property, using an implicit parameter called value. Typically properties read and write from/to fields, private int _salary; public int Salary { get { return _salary; } set { _salary = value; } }   but we can also [...]

Different ways to hide an HTML Element

By |2016-09-05T23:22:20+00:00September 5th, 2016|Categories: Technical|Tags: , |

There are different ways to hide an HTML element from the client, just hiding not removing. <div> <p>Line 1</p> <p class="hide">Line 2</p> <p>Line 3</p> <p>Line 4</p> </div> We need to hide p.hide element, so the user can't see it. Display: Display css property, display is the most important and most used css property to control HTML elements layout. display:none; can be used to hide an HTML element from the view and it will appear as if it was not there on the page, means the HTML element will be hidden without blocking any space. Example: Text 1 | Text 2 | Text [...]

Simplest menu using CSS

By |2018-06-19T14:15:23+00:00October 3rd, 2011|Categories: Technical|Tags: , |

Many web designers I met had problems while  creating menus, specially which contains nested sub menus. In some cases it is a real pain, but in most of cases it is simple, and the problem come when the designer start to implement the simple menu the hard wrong way, it will take ages from him to implement a simple menu while it just need few lines of css code. Also he may think it can’t be done without javascript and jquery. Try to think simple while writing your next menu and may be you will need my code as a starting [...]

Avoid sending Ajax request parameters in query string style

By |2011-06-29T17:36:36+00:00June 29th, 2011|Categories: Technical|Tags: , , |

While reviewing some code, I found someone calling jQuery Ajax like this: $.ajax({       type: "POST",       url: "/AddPost",       data:  "postText="+ PostText ,       dataType: "json",       success: function (status) {        }}); //$.ajax({ And as you see in the previous code, it is sending the data using this line: data: "postText="+ PostText , This is like a query string style, this will work well but image the user inserted a special char in PostText, such as ?? you will get on the server un expected value “"jQuery15107041011152323335_1309357585354"” So never use this style while dealing with Ajax calls, you need to post it in JSON [...]

Javascript based Data Grids

By |2011-04-06T05:26:00+00:00April 6th, 2011|Categories: Technical|

  I found in this blog post some good javascript based grids http://www.queness.com/post/7300/7-robust-and-feature-packed-javascript-grid-plugins   Here are their links: 1- http://flexigrid.info/ 2- http://www.webismymind.be/editablegrid/ 3- http://www.trirand.com/blog/ 4- http://tablesorter.com/docs/ 5- http://www.datatables.net/ 6- https://github.com/mleibman/SlickGrid/wiki 7- http://blog.jqueryui.com/2011/02/unleash-the-grid/

Comments Off on Javascript based Data Grids

Ajax loading gif images generator

By |2011-03-23T21:22:00+00:00March 23rd, 2011|Categories: Technical|

I used to use this web site http://www.ajaxload.info/ to generate ajax loading gif images. Today I found another nice website and it gave me more options to generate custom images: http://preloaders.net   another simple tool: http://fgnass.github.com/spin.js/

Comments Off on Ajax loading gif images generator

List of Colors in System.Drawing.Color

By |2010-12-29T23:57:00+00:00December 29th, 2010|Categories: Technical|

Few lines of code to print all System.Drawing.Color colors on a web page. loop on System.Drawing.Color using KnownColor Label lblColor; Label lblColorName; Panel pnlColorRow; <span class="kwrd">string</span>[] colorNames = System.Enum.GetNames(<span class="kwrd">typeof</span>(KnownColor)); <span class="kwrd">foreach</span> (<span class="kwrd">string</span> colorName <span class="kwrd">in</span> colorNames) { pnlColorRow = <span class="kwrd">new</span> Panel(); Color color = Color.FromName(colorName); lblColor = <span class="kwrd">new</span> Label(); lblColor.BackColor = color; lblColor.Style.Add(<span class="str">&quot;display&quot;</span>, <span class="str">&quot;block&quot;</span>); lblColor.Style.Add(<span class="str">&quot;width&quot;</span>, <span class="str">&quot;50px&quot;</span>); lblColor.Style.Add(<span class="str">&quot;height&quot;</span>, <span class="str">&quot;50px&quot;</span>); lblColor.Style.Add(<span class="str">&quot;float&quot;</span>, <span class="str">&quot;left&quot;</span>); lblColorName = <span class="kwrd">new</span> Label(); lblColorName.Text = color.Name; lblColorName.Style.Add(<span class="str">&quot;display&quot;</span>, <span class="str">&quot;block&quot;</span>); lblColorName.Style.Add(<span class="str">&quot;width&quot;</span>, <span class="str">&quot;50px&quot;</span>); lblColorName.Style.Add(<span class="str">&quot;height&quot;</span>, <span class="str">&quot;50px&quot;</span>); lblColorName.Style.Add(<span class="str">&quot;float&quot;</span>, <span class="str">&quot;left&quot;</span>); pnlColorRow.Height = 70; pnlColorRow.Controls.Add(lblColor); pnlColorRow.Controls.Add(lblColorName); [...]

Comments Off on List of Colors in System.Drawing.Color

How to hide users files and folders on your website?

By |2010-10-31T04:47:00+00:00October 31st, 2010|Categories: Technical|

Sometimes you want to hide some files or folders on your website, so that no one can access them directly. If you have an upload feature in your website, and your website users upload their files or images to your website, It will not be nice to let other users see others files by guessing the URL. For example: Your website uploaded files directory is “UsersUploads” and you put there all the users files, so one file url will be www.example.com/UsersUploads/File1.pdf, another will be www.example.com/UsersUploads/File2.doc . Now a user can guess the URL and access others files specially if your files [...]

Submit form using javascript

By |2010-07-21T01:24:00+00:00July 21st, 2010|Categories: Technical|

Simply to submit a form using javascript you can write: document.getElementById(<span style="color: maroon">&#39;myForm&#39;</span>).submit(); In the following code you will see a special case where the form is not appearing directly on the page but through an iFrame element. <span style="color: blue">&lt;</span><span style="color: maroon">iframe</span>&nbsp;<span style="color: red">id</span><span style="color: blue">=</span><span style="color: blue">&quot;myIFrame&quot;</span>&nbsp;<span style="color: red">name</span><span style="color: blue">=</span><span style="color: blue">&quot;myIFrame&quot;</span>&nbsp;<span style="color: red">src</span><span style="color: blue">=</span><span style="color: blue">&quot;about:blank&quot;</span><span style="color: blue">&gt;<!--</span--><span style="color: maroon">iframe</span><span style="color: blue">&gt;</span> &nbsp;&nbsp;&nbsp; <span style="color: blue">&lt;</span><span style="color: maroon">form</span>&nbsp;<span style="color: red">id</span><span style="color: blue">=</span><span style="color: blue">&quot;myForm&quot;</span>&nbsp;<span style="color: red">name</span><span style="color: blue">=</span><span style="color: blue">&quot;myForm&quot;</span>&nbsp;<span style="color: red">action</span><span style="color: blue">=</span><span style="color: blue">&quot;MyForm.aspx&quot;</span>&nbsp;<span style="color: red">target</span><span style="color: blue">=</span><span style="color: blue">&quot;myIFrame&quot;</span>&nbsp;<span style="color: red">method</span><span style="color: blue">=</span><span [...]