Keep in touch

you can keep in touch with my all blogs and sites by install this Toolbar...
http://rworldtoolbar.ourtoolbar.com/

Saturday, March 6, 2010

ASP.NET: Binding DataList with Images in a Directory

<%@ Page Language="C#" %>
<%@ Import Namespace="System.IO" %>
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">




Pic Album






' style="width:200px" Runat="server" />


<%# Eval("Name") %>





ASP.NET: Programatically Change Page Headers (Title, Stylesheets, Meta)

Private Sub Page_Load()
' Change the title
Page.Header.Title = "My Content Page Title"

' Change the background color
Dim myStyle As New Style()
myStyle.BackColor = System.Drawing.Color.Red
Page.Header.StyleSheet.CreateStyleRule(myStyle, Nothing, "html")

' Create Meta Description
Dim metaDesc As New HtmlMeta()
metaDesc.Name = "DESCRIPTION"
metaDesc.Content = "Content Page Meta Description"

' Create Meta Keywords
Dim metaKeywords As New HtmlMeta()
metaKeywords.Name = "KEYWORDS"
metaKeywords.Content = "Content Page Meta Keywords"

' Add Meta controls to HtmlHead
Dim head As HtmlHead = DirectCast(Page.Header, HtmlHead)
head.Controls.Add(metaDesc)
head.Controls.Add(metaKeywords)
End Sub

This can also be used to override MasterPage setting :)

VB.NET: Write/Create an Excel File

Dim OutputArray(200, 200) As String
Dim strFileName As String = "MyExl.xls"

'set ur OutputArray here

Dim excel As New Microsoft.Office.Interop.Excel.ApplicationClass
Dim wBook As Microsoft.Office.Interop.Excel.Workbook
Dim wSheet As Microsoft.Office.Interop.Excel.Worksheet

wBook = excel.Workbooks.Add()
Try
wSheet = wBook.ActiveSheet()
Dim Range As Microsoft.Office.Interop.Excel.Range = wSheet.Range("A1", wSheet.Cells(200, 200))
Range.Value2 = OutputArray
wBook.SaveAs(strFileName)
Catch ex As Exception
msgbox("Some Error Occured !!!")
Finally
wBook.Close()
excel.Quit()
excel = Nothing
End Try

ASP.NET: GridView with Scrollbar

1. Define Your GridView as






2. Create a style as


3. Add Following code at RowDataBound Event of GridView
Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs)
If e.Row.RowType = DataControlRowType.DataRow Then
If e.Row.RowIndex = 0 Then
e.Row.Style.Add("height", "40px")
End If
End If
End Sub


-------------------------------------------------------------------------------------------------------
Alternativelyyou can simply do this tooo



Oracle: New String Aggregation Techniques

The LISTAGG analytic function was introduced in Oracle 11g Release 2

SELECT deptno, LISTAGG(ename, ',') WITHIN GROUP (ORDER BY ename) AS employees
FROM emp
GROUP BY deptno;

DEPTNO EMPLOYEES
---------- --------------------------------------------------
10 CLARK,KING,MILLER
20 ADAMS,FORD,JONES,SCOTT,SMITH
30 ALLEN,BLAKE,JAMES,MARTIN,TURNER,WARD




If you are not running 11g Release 2

SELECT deptno, wm_concat(ename) AS employees
FROM emp
GROUP BY deptno;

DEPTNO EMPLOYEES
---------- --------------------------------------------------
10 CLARK,KING,MILLER
20 SMITH,FORD,ADAMS,SCOTT,JONES
30 ALLEN,BLAKE,MARTIN,TURNER,JAMES,WARD




Check it out here: http://www.oracle-base.com:80/articles/misc/StringAggregationTechniques.php

ASP.NET: Get Client IP Address

Private Function GetIPs() As StringCollection
Dim localIP = New StringCollection()
Dim localHostName = Dns.GetHostName()
Dim hostEntry = Dns.GetHostEntry(localHostName)
For Each ipAddr As IPAddress In hostEntry.AddressList
localIP.Add(ipAddr.ToString())
Next
GetIPs = localIP
End Function

Tuesday, February 3, 2009

How to: Send Data Using the WebRequest Class

For C#,
=======
using System;
using System.IO;
using System.Net;
using System.Text;

namespace Examples.System.Net
{
public class WebRequestPostExample
{
public static void Main ()
{
// Create a request using a URL that can receive a post.
WebRequest request = WebRequest.Create ("http://www.rushiraval.co.cc);
// Set the Method property of the request to POST.
request.Method = "POST";
// Create POST data and convert it to a byte array.
string postData = "This is a test that posts this string to a Web server.";
byte[] byteArray = Encoding.UTF8.GetBytes (postData);
// Set the ContentType property of the WebRequest.
request.ContentType = "application/x-www-form-urlencoded";
// Set the ContentLength property of the WebRequest.
request.ContentLength = byteArray.Length;
// Get the request stream.
Stream dataStream = request.GetRequestStream ();
// Write the data to the request stream.
dataStream.Write (byteArray, 0, byteArray.Length);
// Close the Stream object.
dataStream.Close ();
// Get the response.
WebResponse response = request.GetResponse ();
// Display the status.
Console.WriteLine (((HttpWebResponse)response).StatusDescription);
// Get the stream containing content returned by the server.
dataStream = response.GetResponseStream ();
// Open the stream using a StreamReader for easy access.
StreamReader reader = new StreamReader (dataStream);
// Read the content.
string responseFromServer = reader.ReadToEnd ();
// Display the content.
Console.WriteLine (responseFromServer);
// Clean up the streams.
reader.Close ();
dataStream.Close ();
response.Close ();
}
}

------------------------------------------------------------------------------------

For VB,
==========
Imports System
Imports System.IO
Imports System.Net
Imports System.Text
Namespace Examples.System.Net
Public Class WebRequestPostExample

Public Shared Sub Main()
' Create a request using a URL that can receive a post.
Dim request As WebRequest = WebRequest.Create("http://www.rushiraval.co.cc ")
' Set the Method property of the request to POST.
request.Method = "POST"
' Create POST data and convert it to a byte array.
Dim postData As String = "This is a test that posts this string to a Web server."
Dim byteArray As Byte() = Encoding.UTF8.GetBytes(postData)
' Set the ContentType property of the WebRequest.
request.ContentType = "application/x-www-form-urlencoded"
' Set the ContentLength property of the WebRequest.
request.ContentLength = byteArray.Length
' Get the request stream.
Dim dataStream As Stream = request.GetRequestStream()
' Write the data to the request stream.
dataStream.Write(byteArray, 0, byteArray.Length)
' Close the Stream object.
dataStream.Close()
' Get the response.
Dim response As WebResponse = request.GetResponse()
' Display the status.
Console.WriteLine(CType(response, HttpWebResponse).StatusDescription)
' Get the stream containing content returned by the server.
dataStream = response.GetResponseStream()
' Open the stream using a StreamReader for easy access.
Dim reader As New StreamReader(dataStream)
' Read the content.
Dim responseFromServer As String = reader.ReadToEnd()
' Display the content.
Console.WriteLine(responseFromServer)
' Clean up the streams.
reader.Close()
dataStream.Close()
response.Close()

End Sub
End Class
End Namespace

}

for detailed, read more