Thursday, December 29

C#, Asp.Net tricks


1.  Display word/ pdf/ image/xml file on page

//Fetch data int SqlDataReader
//Write to Responce
Response.ContentType = dataReader.Item[0]; //ex. word/pdf/image/xml
Response.binarywrite(dataReader.item[1]);

2.Pass querystring value using hyperlink control and open popup window.

<asp:HyperLink ID="HyperLink1"  NavigateUrl="javascript:void(window.open('Default2.aspx?Id=value',null,'width=700,height=500,left=40,top=50'));" runat="server">HyperLinkasp:HyperLink>

3. Clear all Textbox control’s text

foreach (Control control in this.Controls) //Get all controls
{
     if (control.GetType() == TextBox)
     {
          control.text = ""; //Clear TextBox
     }
}

4.Reversing a Sentence.

string inputString = "You Welcome to Csharpings";
string[] arrString = inputString.Split(' ');
Array.Reverse(arrString);
string reverseString = string.Join(" ", arrString);
Response.Write("Original string :"+inputString+"
"
);
Response.Write("Reversed string :" + reverseString);

//Output: Csharpings to Welcome You

5. Open popup window using Ancor Tag

<A title="click here to view Codes" onclick="window.open('PageName.aspx','PageName','width=600,height=500,left=50,top=50,scrollbar=yes')"href="javascript:;">Anchor to open popupA>
 
 
Thanks shibashish mohanty

No comments:

Post a Comment

Please don't spam, spam comments is not allowed here.

.

ShibashishMnty
shibashish mohanty