Saturday, September 27, 2008

Firefox 3.0 now supports showModalDialog()


Javascript function window.showModalDialog() is used to create a modal dialog box that displays the specified HTML document. A modal dialog box, is kind of dialog box which retains the focus while open. The user cannot switch back to parent windows until the dialog box is closed.

This works fine in Internet explorer 4.0 and later version of IE but with Firefox 2.0 or below version it was not working. But there is a good news now that Firefox 3.0 supports showModalDialog() function.


Check out this link..


Test this page in Firefox 2 and Firefox 3



Chrome (Google's new browser) also supports showModalDialog().


Enjoy.....
Virendra Dugar

Saturday, September 20, 2008

Fetch random rows through SQL Query

If you need to fetch random rows from a SQL server table and you have an integer column then using RAND() function goes well. However in some cases there is no number column. In such cases how to fetch random rows? SQL Server provides one more mechanism to access random rows:

SELECT TOP <n>
FROM <table>
WHERE <criteria>
ORDER BY NEWID()

The key is the use of NEWID() function that returns a GUID.

As for example:

SELECT TOP 10 * FROM Products ORDER BY NEWID()

Enjoy Programming....




Monday, June 16, 2008

Text Box and EnableViewState set to false.


Before some days I was just exploring that How EnableviewState works. I noticed one thing that EnableViewState is not working with the textbox. I tried this example

I put a text box with EnableViewState= “false” and a button on the page.

<asp:textbox id="TextBox1" enableviewstate="False" runat="server"/>
<asp:button id="Button1" onclick="Button1_Click" runat="server" text="Button"/>

I entered some value in the text box and When I clicked on the button, the page got refreshed but the text box was maintaining its value.
It was a bit weird thing for me.

After hours of hard work, I came to know this.“Textboxes do not use ViewState to maintain their values across postbacks.These controls simply post their values as normal to the server and then the server simply takes that value and makes it be the default value of the new control generated for the postback. You can see this if you view the source code of the page after the initial form submission, the textbox will have a 'value' attribute set to the data entered into the textbox when it was submitted.”

For more information on this, check out these links..
Microsoft Link
Joteke's Blog

Enjoy..





back to top