Tuesday 8 October 2013

Changing the SiteMaster StyleSheet from Codebehind

- In the SiteMaster Page, add ID to StyleSheet tag:
     <link id="layoutStyleSheet" href="~/Styles/Site.css" rel="stylesheet" type="text/css" />
- In a login page, set a SESSION to a value. e.g. SESSION["user"] = "test"
- In the SiteMaster Page_Load method:
     protected void Page_Load(object sender, EventArgs e)
     {
         if (Session["user"] != null)
         {
             if (Session["user"].ToString() == "test")
             {
                 HtmlLink link = Page.Master.FindControl("layoutStyleSheet") as HtmlLink;
                 link.Href = "~/Styles/Aqualinc.css";
             }
             .
             .
             .       
         }
     }

Wednesday 25 September 2013

Trace HTML textbox changes on the fly using JQuery

$(document).ready(function () {
    var searchValue = "";
    setInterval(checkTextboxChanged, 0.5);

    function checkTextboxChanged() {
        var currentValue = $('#TextBoxId').val();
        if (currentValue != searchValue) {
            searchValue = currentValue;
            TextboxChanged();
        }
    }

    function TextboxChanged() {
        // do your magic here
    }
});
 

Tuesday 17 September 2013

Telerik RadGrid: Access the new values in Update Command

GridEditableItem editItem = e.Item as GridEditableItem;
Hashtable newValues = new Hashtable(); e.Item.OwnerTableView.ExtractValuesFromItem(newValues, editItem);
string inf = newValues["username"].ToString();
.
.
.

After getting all the updated values, they can be passed to SQL update command.

Access input textbox value from the ASP.Net code behind

If you add attribute "runat" & "id" to your input then you can access it in your code behind without using Ajax:

<input type="text" id="myInput" runat="server" />

Tuesday 10 September 2013

C# Partial-Page Update Sample Ajax Application

  • In the AJAX Extensions tab of the toolbox, double-click the ScriptManager control to add it to the page.
  • Drag an UpdatePanel control from the toolbox and drop it underneath the ScriptManager control.
  • Add those controls that you need to be partially updated.
More

Thursday 6 June 2013

.NET WinForms Application Crashes When Run Outside Visual Studio

If you run the application directly of EXE file, try to set "LOCAL COPY = TRUE" for each assembly in the References node and rebuild the project. Execute and try it if run it without problems.


Sunday 21 April 2013

Import CSV Data File Into MySQL Table

LOAD DATA INFILE "D:/test.csv"
INTO TABLE desire_table_name
FIELDS TERMINATED BY ','
OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\r'; 


Wednesday 17 April 2013

Creating a Web Site using Razor Syntax in Visual Studio

ASP.NET Web Pages with Razor syntax provides a simple programming syntax for writing code in Web pages where the server-based code is embedded into the Web page HTML markup. The Razor code runs on the server before the page is sent to the browser. This server code can dynamically create client content—that is, it can generate HTML markup or other content on the fly and then send it to the browser along with any static HTML that the page contains... more


Monday 18 March 2013

Export MySQL Table to a CSV File

SELECT * FROM DatabaseName.DesireTable
INTO OUTFILE 'd:\\output.csv' 
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n';
 

Tuesday 22 January 2013

Microsoft WebMatrix 2

WebMatrix is a free and lightweight web development tool. Create, publish, and maintain your website with ease... more

Upgrade Windows 11 Home to Windows 11 Pro

Disable internet connection (Wi-Fi, Internet, etc.) Change the product key using the following Generic product key:                     VK7J...