Wednesday, January 11, 2012

Executing Script after asp.net validation and before post back


When we have asp.net validators and a onclick client event enabled on the submit button of a form the validations wont fire if we return something in the javascript funciton we called on the click event.
Ex :
<asp:TextBox runat="server" ID="contactpersonnametextbox" ClientIDMode="Static">               </asp:TextBox>
<asp:RequiredFieldValidator ValidationGroup = "savecontact" ControlToValidate = "contactpersonn  ametextbox" runat = "server" Display = "Dynamic" ErrorMessage = "Enter Name of the Contact" F  oreColor = "Red">
</asp:RequiredFieldValidator>
 <asp:Button runat="server" ID="SaveContactButton" ClientIDMode="Static" Text="Save"
   ValidationGroup = "savecontact" OnClick="SavecontactdetailsbuttonClick"
   OnClientClick = "savecontactdetailsbutton_click();" />

When SaveContactButton is clicked savecontactdetailsbutton_click is called before validations because the html that is rendered would be
<input onclick = 'savecontactdetailsbutton_click();WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$MainContent$savecontactdetailsbutton", "", true, "savecontact", "", false, false)')>
So if the savecontactdetailsbutton_click function has any return statement, the validations wont execute.If we want the validations to occur as well the custom script to be executed then we have to call the validations explicitly in the script.

Wednesday, November 16, 2011

Repeat Headers in SSRS on each page and appear on scroll of the Page

This gave me hard time today.Finally figured it out.


To make the row headers to appear in every page and appear on scroll of the page


1) Click the grouping pane of the tablix
2) Click Advanced Mode
3) Set the Following Properties

  1. FixedData -- True
  2. KeepWithGroup -- After
  3. RepeatOnNewPage --True
4)Set FixedColumnHeaders and FixedRowHeaders to false for the tablix

Wednesday, November 2, 2011

Passing Table Valued Parameters to SQL Server Stored Procedures

Passing Table Valued Parameters to SQL Server Stored Procedures

Can also be used to pass arrays to SQL Server
1) Improves performance
2) Easy to Handle
3) Get Rids of  Changing Comma Separated values to table in SQL.

1) Works only with SQL Server 2008 and above

http://msdn.microsoft.com/en-us/library/bb675163.aspx
http://www.dotnetspeaks.com/DisplayArticle.aspx?ID=47