Thursday, October 3, 2013

simple example of how can you use observable to bind html text

Here is code for your html part
First name:

Last name:




this is for your ViewModel which you can use . The noticeable part here is i have used observable instead of using just plain JavaScript strings . so now when any changes made to those properties , changes will also refelect in your model . 
function AppViewModel() {
    this.firstName = ko.observable("Rahul");
    this.lastName = ko.observable("Sharma");
}
// Activates knockout.js
ko.applyBindings(new AppViewModel()); 
Here is output window screen and link of js fiddle 




simple example of knockoutjs of data binding



   


This is a simple *viewmodel* - JavaScript that defines the data and behavior of your UI
function AppViewModel() {
    this.firstName = "Rahul";
    this.lastName = "Sharma";
}
// Activates knockout.js
ko.applyBindings(new AppViewModel()); 

and here is your output screen and link of js fiddle 


Friday, September 27, 2013

Show nice css jquery notification when data is saved using ajax

 showNotification("Success!", "Deduction Detail Saved !", "notice", "br");

// displays Growl notifications
function showNotification(title, msg, type, location) {
    switch (type) {
        case "error":
            $.growl.error({ title: title, message: msg, location: location });
            break;
        case "notice":
            $.growl.notice({ title: title, message: msg, location: location });
            break;
        case "warning":
            $.growl.warning({ title: title, message: msg, location: location });
            break;
        default:
            $.growl.notice({ title: title, message: msg, location: location });
            break;
    }

You also need to reference jQuery Growl jQuery and Growl CSS in your js section .

You can in your ajax call as following  :

$.ajax("yourpagename.aspx/webmethodname", {
            type: 'POST',
            contentType: 'application/json; charset=utf-8',
            data: JSON.stringify({ objDeduction: deductionPageState }),
            dataType: 'json'
        })
        .done(function(data) {
            if (data.d) {
                clearDeductionPage();
                hideLoader();
                showNotification("Success!", "Deduction Detail Saved !", "notice", "br");
                callback(data);
            } else {
                    getRecentErrors(function(data) {
                    hideLoader();
                    showNotification("Error!", "Error in Saving Deduction Details !\n" + data.d.Message, "error", "br");
                });
            }
        })
        .fail(function(xhr, err, msg) {
            hideLoader();
            handleError(xhr, err, msg);
        });


CODE EXCEPTION MONSTERS







Wednesday, September 11, 2013

load log *.txt file in asp.net page using jquery

 

  $('
').load('mytextFile.txt', function (textStr) {
            var htmlStr = $(this).html(textStr).text();
            $(this).html(htmlStr);
        }).appendTo('form');



Tuesday, September 10, 2013

ask for saving new records once clicked on submit



    Untitled Page
   
   

   

   

       
       

       
           
           
           
           
       

       

       
   

   

protected void btnsubmit_Click(object sender, EventArgs e)
        {
            Response.Write("button_clicked");
            string str = "Are you sure, you want to Approve this Record?";
            this.ClientScript.RegisterStartupScript(typeof(Page), "Popup", "ConfirmApproval('" + str + "');", true);
        } 


       
       

       
           
           
           
           
       

       

       
   
 

  function ConfirmApproval(objMsg) {
            if (confirm(objMsg)) {
                $('.txtCheck').attr('disabled', 'disabled');
                $('.ddlCheck').attr('disabled', 'disabled');
                return true;
            }
            else {
                alert("redirected");
                return false;
            }
        } 

Monday, September 9, 2013

best comment in source code

// 
// Dear maintainer:
// 
// Once you are done trying to 'optimize' this routine,
// and have realized what a terrible mistake that was,
// please increment the following counter as a warning
// to the next guy:
// 
// total_hours_wasted_here = 42
// 


//When I wrote this, only God and I understood what I was doing
//Now, God only knows

http://stackoverflow.com/questions/184618/what-is-the-best-comment-in-source-code-you-have-ever-encountered

ASP.NET Core

 Certainly! Here are 10 advanced .NET Core interview questions covering various topics: 1. **ASP.NET Core Middleware Pipeline**: Explain the...