Category : C#


Text wrapping in SSRS Reports in ReportViewer Control 2

In this blog post “Report Viewer wrap text”, we are going to learn an important trick of text wrapping in SSRS reports for long texts (without space and any separator) exceeding the width of a report column’s defined width and being rendered in a Report Viewer control of .Net  Application. Below is the problem explanation in more detail;

I have a report which is rendering through a ReportViewer control in a .Net Web Application. I have defined the width of each and every column in my report. As there are multiple columns in my report and some of which contains long texts without any space or separator. What i want, if the text is too long to fit as per the defined width, the text should be wrapped in next row. I don’t want to expand the column width to accommodate this text in one row. In other words, I

More

URL Rewriting With ASP.NET and C hash

In this article we will learn how to use URL rewriting to map URLs for better search results and user friendly URLs. This comes in handy when we are working with query strings, but don’t actually want to display the query string values to the user. For instance, we could turn the URL ‘~/Default.aspx?page=Books’ into ‘~/Books’.

First, we will need to create a new ASP.NET Empty Web Site and add a new page to it named ‘Default.aspx’. For this example we will be rewriting two URL’s, a ‘Books’ page and an ‘Magazine’ page.

Let’s build our page with links to those pages. To begin, open Default.aspx and:

  • Add a hyperlink control ans set the text  property to Books.
  • Set the NavigateUrl property to ‘~/Books
  • Add a second hyperlink control and set the text property to Magazine.
  • Set the NavigateUrl property to ‘~/Magazine’.

Now we have two different links that we … More


Setting document mode of IE based upon browser mode at run time (C hash) 1

Recently I was working on a project that required me to force the user into IE9 document mode, but ONLY if they were using IE9 compatibility view (CV)  or  IE 10 mode.

The main elements that we need to look at are the Version token and the Trident token. Below are the tokens that you will find in each browser:

                                                          VERSION                   TRIDENT

IE9 StandardMSIE 9.0Trident/5.0
IE9 CVMSIE 7.0Trident/5.0
IE8 StandardMSIE 8.0Trident/4.0
IE8 CVMSIE 7.0Trident/4.0
IE7MSIE 7.0No Trident token
IE6MSIE 6.0No Trident token

As you can see, each browser has a unique combination of these two tokens. We can use this knowledge to now create a function that will tell us what browser mode is in use. My function is shown below:


private string GetIEBrowserMode()

{

string mode = "";

string userAgent = Request.UserAgent; //entire UA string

string browser 
More

Set Width of gridview columns dynamically when AutoGenerateColumns is true 1

Introduction

I faced a lot of problems when I asked to set the width of a gridview dynamically, that is the property AutoGenerateColumns set to AutoGenerateColumns=”true” and the gridview was directly bounded from a dataset in code behind. Thus, we don’t have bound fields to set the width of columns individually. I tried a lot of methods found over the internet but sadly anyone could not help me. But I have overcome the problem using some tricks and am now sharing this article with all of you so that if anyone has a problem like me, he will not get more frustrated.

Background

I used many methods found over the internet, but they could not work for me. Then I used both methods – that is one for bound field and another for setting the AutoGenerateColumns=”true” – individually in two projects and then when page got rendered in browser, I … More