Feeds:
Posts
Comments

Archive for May, 2008

This tip provides a way to access the user control’s variables inside an ASP.NET
Web page.

Assume that strVar is the variable declared in the user control’s code-behind
file. To access the variable in the ASP.NET Web page called webform1.aspx,
follow these two steps:

Declare strVar as public in the user control’s code.

Use the Register directive to register the user control in the Web page called
webform1.aspx.

<%@ Register TagPrefix=”UC” TagName=”MyCon” src=”webusercontrol1.ascx”%>

The following shows how to instantiate the user control:

<uc:mycon id=”mycon1″ runat=”server”></uc:mycon>

This is the actual way to access the variable:

<%= mycon1.strVar %>

Read Full Post »

Asp.Net 2.0 Menu Control is not working with Mac Safari browser properly.
Use below code to your page_load event and see the magic

if (Request.UserAgent.IndexOf(“AppleWebKit”) > 0)
{

Request.Browser.Adapters.Clear();

}
if you are using Master page then paste this code into master page code behind page.

for more detail Click here

Read Full Post »

A control adapter allows you to plug-into any ASP.NET server control and override, modify and/or tweak the rendering output logic of that control.

What is cool about control adapters is that they do not require a page developer to program against a new control, or modify the control programming model semantics (you still use the same control properties, methods, events and templates you did before). Indeed – a page developer can be entirely oblivious that a control adapter is being used (the control adapter model makes it very clean to register and encapsulate this support).

The CSS Control Adapter Toolkit includes a bunch of pre-built control adapter samples that show how you can use the control adapter architecture to emit 100% CSS based rendering output (no tables or inline styles – instead use external CSS stylesheets for everything). ……..Read More

Download CSS Adapter toolkit

Read Full Post »

Redirecting to the real referrer page during a postback
Say that you have a page loaded from another page, and that in this page you have a “Save and Return” button that does something and returns to the previous page. For example you may have an Orders page that loads a Details page, where you make some changes and press the button to save the changes and return to the Orders page. You may think that the following code would work just fine:

Response.Redirect(Request.UrlReferrer.ToString())

But this isn’t the case. In fact, when a web form submits itself and generates a postback, the referrer page becomes the page itself! The solution is very simple though. When the page is first loaded (i.e. it is not a postback), you save the real referrer page in the page’s ViewState:

Private Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
If Not Page.IsPostBack Then
‘ Save the referrer Url
ViewState(“ReferrerUrl”) = Request.UrlReferrer.ToString()
End If
End Sub

Then, when the “Save and Return” is clicked you retrieve the Url saved in the ViewState, and redirect to it:

Protected Sub SaveAndReturn_Click(ByVal sender As Object, ByVal e As EventArgs)
‘ do something here, e.g. add/update some DB records

‘ redirect to the previous page
Response.Redirect(ViewState(“ReferrerUrl”).ToString())
End Sub

This tip is taken from Marco Bellinaso’s and Kevin Hoffman’s “ASP.NET Website Programming – VB.NET edition” (Wrox Press).

Read Full Post »

You can define parameters for the SqlDataSource control. If a parameter value is
an empty string, the driver automatically converts that into a NULL value, which
can lead to unexpected query resultsand sometimes to no query results at all.

To avoid this automatic conversion, set the ConvertEmptyStringToNull to equal
false in the SqlDataSource control.

Here’s an example:

<asp:SqlDataSourceControl id=”SqlDataSource1″ RunAt=Server >

<SelectParameters>

<asp:Paramter Name=”parameter1″ ConvertEmptyStringToNull=false> </asp:Parameter>

</SelectParameters>

</asp:SqlDataSourceControl>

Read Full Post »