How do I access an element of a control template from within code-behind

You need to get the template and locate the control by name on the templated control, something like: var template = MyList.Template; var myControl = (MyControl)template.FindName(“MyControlName”, MyList); Templates are just that: Abstract descriptions of what is to be created, the controls in templates only exist in the context of something that is being templated. Note … Read more

How to call a C# function from JavaScript?

You can use a Web Method and Ajax: <script type=”text/javascript”> //Default.aspx function DeleteKartItems() { $.ajax({ type: “POST”, url: ‘Default.aspx/DeleteItem’, data: “”, contentType: “application/json; charset=utf-8”, dataType: “json”, success: function (msg) { $(“#divResult”).html(“success”); }, error: function (e) { $(“#divResult”).html(“Something Wrong.”); } }); } </script> [WebMethod] //Default.aspx.cs public static void DeleteItem() { //Your Logic }

I want to insert a record in DB and then need to return a row

One way to do what you want is to modify @voucherNo to be an OUTPUT parameter, and add a new OUTPUT parameter to your query to return the value of SCOPE_IDENTITY(). @voucherNo varchar(max) @ScopeIdentity numeric(38,0) And modify that last SELECT statement to set the value of @ScopeIdentity parameter. SELECT @ScopeIdentity = SCOPE_IDENTITY() Then use SqlCommand.ExecuteNonQuery … Read more