Posts Tagged ‘ASP.NET’

How to Access Parent Page (.aspx) control (IDs) from its child User Control (.ascx)

November 5, 2015 Leave a comment

Write below line of code in control to find relevant parent page (aspx page)’s control

Code for VB.NET

Dim MainContent As ContentPlaceHolder = Me.Page.Master.FindControl(“MainContent”)

Dim btnPrint As Button = MainContent.FindControl(“btnPrint”)


Hope this help !



Page Life Cycle

Page Life Cycle


Seq Events Controls Initialized View state
Form data
What Logic can be written here?
1 Init No No No Note: You can access form data etc. by using ASP.NET request objects but not by Server controls.Creating controls dynamically, in case you have controls to be created on runtime. Any settinginitialization.Master pages and them settings. In this section, we do not have access to viewstate , posted values and neither the controls are initialized.
2 Load view state Not guaranteed Yes Not guaranteed You can access view state and any synch logic where you want viewstate to be pushed to behind code variables can be done here.
3 PostBackdata Not guaranteed Yes Yes You can access form data. Any logic where you want the form data to be pushed to behind code variables can be done here.
4 Load Yes Yes Yes This is the place where you will put any logic you want to operate on the controls. Like flourishing a combobox from the database, sorting data on a grid, etc. In this event, we get access to all controls, viewstate and their posted values.
5 Validate Yes Yes Yes If your page has validators or you want to execute validation for your page, this is the right place to the same.
6 Event Yes Yes Yes If this is a post back by a button click or a dropdown change, then the relative events will be fired. Any kind of logic which is related to that event can be executed here.
7 Pre-render Yes Yes Yes If you want to make final changes to the UI objects like changing tree structure or property values, before these controls are saved in to view state.
8 Save view state Yes Yes Yes Once all changes to server controls are done, this event can be an opportunity to save control data in to view state.
9 Render Yes Yes Yes If you want to add some custom HTML to the output this is the place you can.
10 Unload Yes Yes Yes Any kind of clean up you would like to do here.


Reference :


Categories: ASP.NET Tags: ,

File Download code in

If Not String.IsNullOrEmpty(strURL) Then
Dim req As New WebClient()
Dim response As HttpResponse = HttpContext.Current.Response
response.Buffer = True
response.AddHeader(“Content-Disposition”, “attachment;filename=””” + Server.MapPath(strURL) + “”””)
Dim data As Byte() = req.DownloadData(Server.MapPath(strURL))
End If


Hope it helps !

SalesForce (Login) Integration With ASP.NET

April 24, 2015 1 comment


  1. Add Service Reference, select Advanced and then select Add Web Reference.
  2. In the URL box of the Add Web Reference dialog box, type the URL to obtain the service description of the XML Web service you want to access, such as:


  3. Click Go to retrieve information about the XML Web service.
  4. In the Web reference name box, rename the Web reference to sforce, which is the name you will use for this Web reference.
  5. Click Add Reference to add a Web reference for the target XML Web service.
  6. Visual Studio retrieves the service description and generates a proxy class to interface between your application and the XML Web service.

Issues :

error CS0030: Cannot convert type ‘SFDC.ListViewRecordColumn[]’ to ‘SFDC.ListViewRecordColumn’
error CS0030: Cannot convert type ‘SFDC.ListViewRecordColumn[]’ to ‘SFDC.ListViewRecordColumn’
error CS0029: Cannot implicitly convert type ‘SFDC.ListViewRecordColumn’ to ‘SFDC.ListViewRecordColumn[]’
error CS0029: Cannot implicitly convert type ‘SFDC.ListViewRecordColumn’ to ‘SFDC.ListViewRecordColumn[]’


Add following to enterprise.wsdl.xml

<xsd:attribute name=”tmp” type=”xsd:string”></xsd:attribute>


<complexType name=”ListViewRecord”>
<element name=”columns” type=”tns:ListViewRecordColumn” maxOccurs=”unbounded”/>
<xsd:attribute name=”tmp” type=”xsd:string”></xsd:attribute>

Hope this help!

Full form

March 30, 2015 Leave a comment

WSDL : Web Services Description Language
REST : Representational State Transfer
SOAP : Simple Object Access Protocol

..Will add some more soon

REST Services

REST : Representational State Transfer

Principle of REST Services

  1. Everything is resource
  2. Every resource identified by unique URI
  3. User simple and uniform interface (like GET, POST, PUT, DELETE)
  4. All communication done via Representation
  5. Be Stateless

Will add some information soon !


Operation is not valid due to the current state of the object.

Error : Operation is not valid due to the current state of the object.

When there is a postback with large number of form fields such error occurs.

Stack trace :
at System.Web.HttpValueCollection.ThrowIfMaxHttpCollectionKeysExceeded() at System.Web.HttpValueCollection.FillFromEncodedBytes

By default, the maximum value of MaxHttpCollection is 1000.
To solve this error, increase the MaxHttpCollection value. Try adding the following setting in your web.config’s <appsettings> block.


<add key=”aspnet:MaxHttpCollectionKeys” value=”2001″ />


Javascript ‘confirm()’ Cancelling Post Back

November 24, 2014 Leave a comment

Problem : Postback is not working on javascript confirm() Click

Solution :

 <asp:Button runat="server" ID="btnSubmit" Text="Submit" OnClick="BtnSubmit_Click"
 OnClientClick="if (!confirm('Are you sure you want to Submit?')) return false;"/>

Hope this help !



Visual Studio 2013 ‘Could not evaluate Expression’ Debugger

October 9, 2014 1 comment










Solution :



Hope It Helps!


remove pie chart slices labels in

December 24, 2013 Leave a comment




  <Series Name="Series1" ChartType="Pie" CustomProperties="PieLabelStyle=Disabled">

This will hide labels appearing on the pie chart.( There may be other options available but this one is useful to me)

Hope it helps !