18 December 2012

Click the button using Javascript


Click the button using Javascript 

document.getElementById("btnSearch").click();



Javascript Empty validation in Asp.net


Javascript Empty validation

function CheckEmpty() {

           try {
               if (document.getElementById("txtClientNumber").value.trim() == "") {
                   alert("Must enter a Client Number");
                   return false;
               }
           }
           catch (e) {
           }
       }
     

calling javascript from server side
btnAdd.Attributes.Add("onclick", "return CheckEmpty();")



Asp.net Gridview mouseover, mouseout color change in C#


Asp.net Gridview mouseover, mouseout color change in C#


protected void grd_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        try
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                e.Row.Attributes["onmouseover"] = "this.style.cursor='hand';this.style.color='Red'";
                e.Row.Attributes["onmouseout"] = "this.style.textDecoration='none';this.style.color='Black'";

                e.Row.Attributes["onclick"] = ClientScript.GetPostBackClientHyperlink(this.grd, "Select$" + e.Row.RowIndex);
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }

    }

Confirm ok/cancel in Javascript in Asp.net


Confirm ok/cancel in Javascript in Asp.net


function askConfirm()
{
    if (confirm("Are you sure want to overwrite the file")) {
    }
    else {

        return false;
    }


Calling js from server side coding in Asp.net

 ScriptManager.RegisterStartupScript(this, GetType(), "YourUniqueScriptKey", "askConfirm();", true);






Stored Procedure used to search the word in the Database Sql Server


Below Stored Procedure used to search the word in the Database Sql Server
/*


Test Script:
exec Find_Text_In_SP 'Searchword'


*/

CREATE Procedure dbo.Find_Text_In_SP(
@SearchString AS VARCHAR(500)
)
AS
BEGIN
SET NOCOUNT ON
SELECT name
FROM
 sysobjects
WHERE
 id IN
 (SELECT id
  FROM
   syscomments
  WHERE
   text LIKE '%' + @SearchString + '%')
ORDER BY
 name
END





14 December 2012

The MVC Programming Model in Asp.net


The MVC Programming Model in Asp.net


MVC is one of three ASP.NET programming models.
MVC is a framework for building web applications using a MVC (Model View Controller) design:

The Model-View-Controller (MVC) pattern separates the modeling of the domain, the presentation, and the actions based on user input into three separate classes:
  • Model. The model manages the behavior and data of the application domain, responds to requests for information about its state (usually from the view), and responds to instructions to change state (usually from the controller).
  • View. The view manages the display of information.
  • Controller. The controller interprets the mouse and keyboard inputs from the user, informing the model and/or the view to change as appropriate.
    Ff649643.des_MVC_Fig01(en-us,PandP.10).gif

    It is important to note that both the view and the controller depend on the model. However, the model depends on neither the view nor the controller. This is one the key benefits of the separation. This separation allows the model to be built and tested independent of the visual presentation. The separation between view and controller is secondary in many rich-client applications, and, in fact, many user interface frameworks implement the roles as one object. In Web applications, on the other hand, the separation between view (the browser) and controller (the server-side components handling the HTTP request) is very well defined.

  • Consistency level in Azure cosmos db

     Consistency level in Azure cosmos db Azure Cosmos DB offers five well-defined consistency levels to provide developers with the flexibility...