WebParts Cross- browser drag and drop is a very common issues on ASPNET WebPart Framework.. Basically WebParts doesn't support the Drag and Drop feature in Firefox browsers and this known to be a BUG for ASPNET Webpart Framework.. To get things working in all browsers including the cross browser drag-and-drop feature then you would need to use Visual studio 2008 / VWD 2008 with latest version of the Microsoft ASPNET Futures (AJAX Control Toolkit 3.5)..
For more detail information then i would suggest you to read the following article below
http://waitink.blogspot.com/2008/06/ajax-web-parts-part-1-drag-and-drop.html
We also discuss the issues in the following links below
http://forums.asp.net/t/1277540.aspx
http://forums.asp.net/p/1087200/1943716.aspx#1943716
The following snippet below describes on how we are going to limit the Text displayed in the boundfield column of the GridView and display the original data in the ToolTip when user hovers the mouse for a particular cell.
C#
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
ViewState["OrigData"] = e.Row.Cells[0].Text;
if (e.Row.Cells[0].Text.Length >= 30) //Just change the value of 30 based on your requirements
{
e.Row.Cells[0].Text = e.Row.Cells[0].Text.Substring(0, 30) + "...";
e.Row.Cells[0].ToolTip = ViewState["OrigData"].ToString();
}
}
}
VB.NET
Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs)
If e.Row.RowType = DataControlRowType.DataRow Then
ViewState("OrigData") = e.Row.Cells(0).Text
If e.Row.Cells(0).Text.Length >= 30 Then 'Just change the value of 30 based on your requirements
e.Row.Cells(0).Text = e.Row.Cells(0).Text.Substring(0, 30) + "..."
e.Row.Cells(0).ToolTip = ViewState("OrigData").ToString()
End If
End If
End Sub
That simple! Hope it Helps!
Here's an example on how to pass Multiple querystrings in the page..
Page1
protected void Button1_Click(object sender, EventArgs e)
{
string strName = "VINZ";
string strAddress = "CEBU";
string strDate = DateTime.Now.ToShortDateString();
Response.Redirect(string.Format("TestNasad2.aspx?param1={0}¶m2={1}¶m3={2}",strName,strAddress,strDate));
}
The on Page2 you can get each values this way below
protected void Page_Load(object sender, EventArgs e)
{
if ((Request.QueryString["param1"] != null && Request.QueryString["param2"] != null) && Request.QueryString["param3"] != null)
{
string name = Request.QueryString["param1"];
string address = Request.QueryString["param2"];
string date = Request.QueryString["param3"];
}
}
Hope this Helps!
The snippet below describes on how we are going to validate the user credentials being supplied by the end user in Login page using the ADO.NET way..
C#
protected void ValidateUserInfo(string user, string pass)
{
SqlConnection connection = new SqlConnection("YOUR CONNECTION STRING HERE");
string sql = "SELECT * FROM TableName WHERE UserID = @username AND Password = @password";
SqlCommand cmd = new SqlCommand(sql,connection);
cmd.Parameters.AddWithValue("@username", user);
cmd.Parameters.AddWithValue("@password", pass);
connection.Open();
DataTable dt = new DataTable();
SqlDataAdapter ad = new SqlDataAdapter(cmd);
ad.Fill(dt);
if (dt.Rows.Count > 0) { //check if the query returns any data
//Valid Username and Password
Response.Redirect("Default.aspx");
}
else
{
Response.Write("INVALID Username and Password, Try Again!");
}
connection.Close();
}
protected void Button1_Click(object sender, EventArgs e)
{
ValidateUserInfo(TextUserName.Text.Trim(), TextPassword.Text.Trim());
}
VB.NET
Protected Sub ValidateUserInfo(ByVal user As String, ByVal pass As String)
Dim connection As New SqlConnection("YOUR CONNECTION STRING HERE")
Dim sql As String = "SELECT * FROM TableName WHERE UserID = @username AND Password = @password"
Dim cmd As New SqlCommand(sql, connection)
cmd.Parameters.AddWithValue("@username", user)
cmd.Parameters.AddWithValue("@password", pass)
connection.Open()
Dim dt As New DataTable()
Dim ad As New SqlDataAdapter(cmd)
ad.Fill(dt)
If dt.Rows.Count > 0 Then
'check if the query returns any data
Response.Redirect("Default.aspx")
Else
Response.Write("INVALID Username and Password, Try Again!")
End If
connection.Close()
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1_Click
ValidateUserInfo(TextUserName.Text.Trim(), TextPassword.Text.Trim())
End Sub
That simple! Happy Coding!
This sample snippet below describes on how we are going to Populate a TextBox and Label control in the page based on the data associated per user using the ADO.NET way..
C#
private void getData(string user)
{
DataTable dt = new DataTable();
SqlConnection connection = new SqlConnection("YOUR CONNECTION STRING HERE");
connection.Open();
SqlCommand sqlCmd = new SqlCommand("SELECT * from TABLE1 WHERE UserID = @username", connection);
SqlDataAdapter sqlDa = new SqlDataAdapter(sqlCmd);
sqlCmd.Parameters.AddWithValue("@username",user);
sqlDa.Fill(dt);
if (dt.Rows.Count > 0)
{
TextBox1.Text = dt.Rows[0]["ColumnName1"].ToString(); //Where ColumnName is the Field from the DB that you want to display
TextBox2.Text = dt.Rows[0]["ColumnName2"].ToString();
Label1.Text = dt.Rows[0]["ColumnName3"].ToString();
Label2.Text = dt.Rows[0]["ColumnName4"].ToString();
}
connection.Close();
}
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack){
getData(this.User.Identity.Name);
}
}
VB.NET
Private Sub getData(ByVal user As String)
Dim dt As New DataTable()
Dim connection As New SqlConnection("YOUR CONNECTION STRING HERE")
connection.Open()
Dim sqlCmd As New SqlCommand("SELECT * from TABLE1 WHERE UserID = @username", connection)
Dim sqlDa As New SqlDataAdapter(sqlCmd)
sqlCmd.Parameters.AddWithValue("@username", user)
sqlDa.Fill(dt)
If dt.Rows.Count > 0 Then
TextBox1.Text = dt.Rows(0)("ColumnName1").ToString() 'Where ColumnName is the Field from the DB that you want to display
TextBox2.Text = dt.Rows(0)("ColumnName2").ToString()
Label1.Text = dt.Rows(0)("ColumnName3").ToString()
Label2.Text = dt.Rows(0)("ColumnName4").ToString()
End If
connection.Close()
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
If Not Page.IsPostBack Then
getData(Me.User.Identity.Name)
End If
End Sub
Note: Don't forget to declare the following Namespaces below for you to make it work.
For C#:
Using System.Data;
Using System.Data.SqlClient;
For VB.NET
Imports System.Data;
Imports System.Data.SqlClient;
That simple! Hope this will be useful for you..