Thursday, November 24, 2011

Connect to SSEE db via Management Studio

To connect to a SSEE (SQL Server Embedded Edition) database via SqlServer Management Studio you can use the following string as Server Name:


Tuesday, October 4, 2011

jQuery modal alert in Page_Load

To insert a jQuery alert into Page_Load method of an our WebForm (maybe for a bad result of an operation) could not be simple, 'cause Page_Load method is invoked before thar the page loads included script files.

To solve it, just do this:

Protected Sub Page_Load(sender As Object, e As System.EventArgsHandles Me.Load

ScriptManager.RegisterClientScriptInclude(Page, Page.GetType, Guid.NewGuid().ToString(), Page.ResolveUrl("~/js/jquery-1.6.2.min.js"))
        ScriptManager.RegisterClientScriptInclude(Page, Page.GetType, Guid.NewGuid().ToString(), Page.ResolveUrl("~/js/jquery-ui-1.8.16.custom.min.js"))
        Dim sb As New StringBuilder
        sb.Append("$(function() { ")
        sb.Append(" $( '#dialog-message-error' ).dialog({")
        sb.Append("    modal: true,")
        sb.Append("    buttons: {")
        sb.Append("        Ok: function() {")
        sb.Append("               $( this ).dialog( 'close' );")
        sb.Append("        }")
        sb.Append("    }")
        sb.Append(" });")
        ScriptManager.RegisterClientScriptBlock(Page, Page.GetType, Guid.NewGuid().ToString(), sb.ToString, True)
End Sub

It's supposed to have jquery and jquery-ui script files into the "js" folder on application root, and that this div exists:

<div id="dialog-message-error" title="Error" style="display: none; font-size: small">
<div class="ui-state-error ui-corner-all" style="padding: 0 .7em;">
<span class="ui-icon ui-icon-alert" style="float: left; margin-right: .3em;">span>
<strong>Error:strong> Error text....

Monday, October 3, 2011

Android: Screen dimensions and orientation

/* get display from WindowManager */
Display display = ((WindowManager) getSystemService(WINDOW_SERVICE)).getDefaultDisplay();
/* get infos */
int width = display.getWidth();
int height = display.getHeight();
int orientation = display.getOrientation();

Thursday, September 29, 2011

Android: Dial a phone number

import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;

public class DialANumber extends Activity {
      EditText mEditText_number = null;
      LinearLayout mLinearLayout_no_button = null;
      Button mButton_dial = null;
      public void onCreate(Bundle savedInstanceState) {
            mLinearLayout_no_button = new LinearLayout(this);
            mEditText_number = new EditText(this);
            mButton_dial = new Button(this);
            mButton_dial.setOnClickListener(new View.OnClickListener() {
                  public void onClick(View v) {
      public boolean onKeyDown(int keyCode, KeyEvent event) {
            if (keyCode == KeyEvent.KEYCODE_CALL) {
                  return true;
            return false;
      public void performDial(){
                  try {
                        startActivity(new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + mEditText_number.getText())));
                  catch (Exception e)

Tuesday, September 27, 2011

Android: Load image from web

public Bitmap getRemoteImage(final URL aURL) {
      try {
            final URLConnection conn = aURL.openConnection();
            final BufferedInputStream bis = new BufferedInputStream(conn.getInputStream());
            final Bitmap bm = BitmapFactory.decodeStream(bis);
            return bm;
      } catch (IOException e) {
      return null;

Tuesday, September 20, 2011

DataTable sorting

Sort a DataTable is a very simple activity:

dt.DefaultView.Sort = "ColumnName"  'normal DataTable 

ds.Tables("TableName").DefaultView.Sort = "ColumnName"  'DataTable in DataSet

dt.DefaultView.Sort = "ColumnName"  'normal DataTable

ds.Tables["TableName"].DefaultView.Sort = "ColumnName"  'DataTable in DataSet

With this snippet you don't "physically" order the content of the DataTable but it's default view. But for data visualization purpose and other the result is the same.
Using this DataTable, for example, as datasource for a GridView the list will be sorted based of the used criteria (ColumName).

UpdateProgress dinamically centered

<script language="JavaScript" type="text/javascript">
        function adjustDivs() {           
            internal= document.getElementById('divCalculateInt');
            external= document.getElementById('divCalculate');
            dfs =;
            dfs.left = (external.innerWidth - internal.offsetWidth) / 2;

        window.onload = adjustDivs;
        window.onresize = adjustDivs;
        window.onscroll = adjustDivs;

<asp:UpdatePanel ID="updXXX" runat="server">

<asp:UpdateProgress ID="updprogXXX" runat="server" AssociatedUpdatePanelID="updXXX" DisplayAfter="150">
             <div id="divCalculate" align="center" style="top: 200px; position: absolute; top:0; bottom:0; right:0; left:0;background-color:rgba(0,0,0,0.5)">
                    <div id="divCalculateInt" align="center" style="border: solid 1px #000000; background: #FFFFFF;padding: 5px; width: 320px; height: 50px;margin-top:300px">
                        <asp:Label runat="server" ID="lblLoading2" Text="Computing in progress..."><asp:Label>
                        <asp:Image ID="imgLoading" runat="server" ImageAlign="left" SkinID="imgLoadingBar" /><br /><br />
                        <asp:Label runat="server" ID="lblLoadingInfo" Text="This operation may last some minutes" Font-Size="X-Small" >asp:Label>

Wednesday, May 4, 2011

Using C# and togheter in

To use in the same Web Application classes written in different languages, such C# and, you have to do this steps:

Create in the App_Code folder two subfolder, called for example VB and CS:


Next, add in the web.config this lines:
add directoryName="CS"/>
<add directoryName="VB"/>

And voila, its done!

PS: obviously, you have to put all classes in a folder and all the c# classes in the other folder...