Friday, June 01, 2007
Capturing F1 in javascript
OnKeyPress doesn't gets fired when pressing functional keys, however, we are able to capture F1 by inserting the following script:
<script language="javascript">
document.onhelp = function()
{
alert("help"); // instead of an alert you can define custom content
return false; // necessary for cancel original F1 event
}
</script>
Vertical alignment in DIV panel
<div style="width: 100px; height: 100px; line-height: 100px; text-align: center; border: 1px solid red;">acontent</div>
Special thanks to Erika :).
Wednesday, May 16, 2007
Monday, February 26, 2007
Hidden field's value gets lost
Wednesday, February 21, 2007
Friday, February 09, 2007
Make a page refresh after a form submit
Thursday, January 25, 2007
Create ActiveX Component in .Net
1. Create a new Class Library project.
2. When the project is created, add a new User Control to it, then add the controls, methods and properties you need.
3. To make it work, you need to expose the interface for the control. This is how COM/COM+ objects will know which are the properties they can use.
...
namespace ActiveXComponent
{
public interface IActiveXControl
{
string Title{ set; get ; }
...
}
public class ActiveXControl : System.Windows.Forms.UserControl, IActiveXControl
{
private string _title;
public string Title
{
get { return _title; }
set { _title = value; }
}
...
}
}
4. Compile the project, and copy the resulted .dll in your client application. Then embed the created user control in a web page.
<OBJECT id="ActiveXControl 1" name="ActiveXControl 1" classid="ActiveXComponent.dll#ActiveXComponent.ActiveXControl"></OBJECT>
5. You can make use of it's exposed methods and properties on client side. For example:
<script language = "javascript">
var myctrl1 = document.getElementById('ActiveXControl1');
myctrl1.Title = 'My first activeX component';
<script>
Tuesday, November 21, 2006
VB COLOR CONVERSION
What can we do with a VBColor in C#? For example, let's take vbRed = 255.
exp: 12615935(dec) = C080FF(hex) in BGR = FF80C0(hex) in RGB
Friday, November 03, 2006
MSSQL RESULT CACHING
Strange issue:I have an sql user-function, which returns the result of a select statement, thus, a table. The server never stopped, and we modified something else in our database, and so, there should be a column with modified values in that table.The problem is, that while running the select statement of the function returns the expected result, calling the function by: select * from functionName ... returns the table with the original column values.From my opinion, this should only happen, if there is a result caching for user-defined-functions!
And it is the reason. For all stored procedures and function there is a result caching.The cache can be cleared with:
DBCC FREEPROCCACHE
Monday, October 30, 2006
HEXAGONAL PANEL?
What if, we need a panel, that would hold two controls in the following manner:
Well, hexagonal panels do not exist, but we can simulate them by changing two style attributes of the second control. The panel still holds both controls, even if it is not so obvious any more.
Thursday, October 26, 2006
GOOD TO KNOW!
All controls, that require their state to be maintained in ViewState should be initialized (created) before the LoadViewstate event.
Thanks, Attila!
Wednesday, October 25, 2006
WHEN IT DOESN'T WORK - element.setAttribute(...) - javascript
Examples for using element.setAttribute("att_name","att_value") in javascript:
element.setAttribute("src","../Pictures/x.jpg"); // OK, it works.
element.setAttribute("style","cursor: hand;"); // NOT OK, it doesn't work.
So, when trying to add style attributes to elements in javascript, instead of the previous line use:
element.style.setAttribute("cursor","hand",0); // OK, it works.
Thursday, October 19, 2006
MANIPULATING DATAGRIDS IN JAVASCRIPT
Manipulating DropDownLists for example, in javascript, is similar to manipulating ListBoxes. However, if we want to add/remove items to/from a DataGrid, we have to act somewhat else. A DataGrid control is rendered as a Table with several TableRows, and TableColumns.
Adding a row to a grid with 2 columns:
var lastRow = grid.rows.length;
var row = grid.insertRow(lastRow);
var cellLeft = row.insertCell(0);
var textNode = document.createTextNode("col1/rowx");
cellLeft.appendChild(textNode);
var cellRight = row.insertCell(0);
var textNode2 = document.createTextNode("col2/rowx");
cellRight.appendChild(textNode2);
Deleting a row from the same grid:
grid.deleteRow(index); // 1<= index < grid.rows.length - if the grid has a header.
Thursday, October 05, 2006
MANIPULATING LISTBOXES IN JAVASCRIPT
Ever occured the problem of moving elements from one ListBox to another? It can be done easily on server side, but what if you could get rid of those annoying postbacks? Here's a tip:
<select ...>
<option value="aaaaa">aaaaa</option>
<option value="bbbb">bbbb</option>
<option value="ccc">ccc</option>
...
</select>
The following code snippets might be useful in such case:
1. you need to have an array with all elements of the first ListBox
var myListbox = document.getElementById(lb1Id); // lb1Id is the ClientId of the control
var myListboxOptions = myListbox.getElementsByTagName("option");
2. need a clone of the original ListBox and a clone of all options
var cloneOfMyListbox = myListbox.cloneNode(true);
var cloneOfMyListboxOptions = cloneOfMyListbox.getElementsByTagName("option");
3. you need the other ListBox
var otherListbox = document.getElementById(lb2Id); //lb2Id is the ClientId of the second control
4. and the mechanisms for moving certain elements from the first ListBox to the second one
otherListbox.appendChild(cloneOfMyListboxOptions[index].cloneNode(true)); // add element to the second control
myListbox.remove(index); // remove the element on the specific index from the first control
Friday, September 01, 2006
Wednesday, August 02, 2006
<tagname> - egy post-ban
< = & l t ;
> = & g t ;
P.S. a kódokat nyilván szóköz nélkül kell használni.
HTC
A HTC file is nothing but an HTML file, saved with a .htc extension. It contains scripts and a set of HTC-specific custom elements, that define the component.
Objects:
document - the HTML document in a given browser window
PUBLIC: ATTACH - binds a function to an event
PUBLIC: COMPONENT - identifies the content of the file as HTC
PUBLIC: DEFAULTS - sets default properties for an HTC
PUBLIC: EVENT - defines an event
PUBLIC: METHOD - defines a method
PUBLIC: PROPERTY - defines a property of the HTC
element - returns a reference to the tag in the primary document, to which the behavior is attached
exp.
attaching behavior to a simple asp TextBox:
TextBox _myTextBox;
...
_myTextBox.Style.Add("behavior","url(myhtcfile.htc)");
where the HTC file should look like this:
<PUBLIC: COMPONENT>
<PUBLIC: PROPERTY name="propertyName" />
<PUBLIC: ATTACH event="eventName" handler="MyEventHandler"/>
...
<SCRIPT language="JScript">
function MyEventHandler()
{ ... }
</SCRIPT>
</PUBLIC: COMPONENT>
and the file name should be:
myhtcfile.htc
Friday, July 14, 2006
SAVE A .GIF WITH TRANSPARENT BACKGROUND - in Ms Expression
Need to create a picture with transparent background?
This is the way to do it, using Microsoft Expression:
1. Open a new file in Pixel Layer
2. Choose the Magic Eraser Tool, then click on the paper
3. Do the drawing
4. Save the file by Export: Export » to Image Format » gif » Save Alpha Channel
The background will be transparent.
Tuesday, July 11, 2006
EXCEL SHEET ÜRES SORAINAK KITÖRLÉSE - VBA makró
Sub RemoveEmptyRowsFromASpecificSheet()
Dim rng As String
rng = ""
totalrows = Sheets("SpecificSheet").UsedRange.Rows.Count
For Row = 1 To totalrows Step 1
If Sheets("SpecificSheet").UsedRange.Cells(Row, 1).Value = "" Then
rng = "A" + CStr(Row) + ":P5000"
Exit For
End If
Next Row
Sheets("SpecificSheet").Range(rng).EntireRow.Delete
End Sub

