|
 |
aspx thread: RE: CONFIRMED: Re: Viewstate not working for listboxes...
Message #1 by "Sampath, Ramanujam (Cognizant)" <SRamanuj@c...> on Wed, 21 Aug 2002 19:57:46 +0530
|
|
Well greg...
Now if u have removed the view state property then in the page_load
remove the postback property and call the populateList() each time the
pageload is called...
Now u have a problem.. Now u click on a item in a listboax and want
to post some values into the server depending upon which item is clicked
then u will face problem, because when it goes to server then the page_load
is called and the values are refreshed and so selectedItem will be null...
so to solve this write a client-Side script which will store the
SelectedItem in the List before it goes to the server and then oppulate it
when the postback to server happens....
keep me posted if the problem exists....
S.Ramanujam
Programmer Analyst
38 & 39 Whites Road,
WCB - Whites Road Circular Building
Royapettah, Chennai - 600014
Ph : +xx xx xxx xxxx Extn 5113 [Off]
: +xx xx xxx xxxx [Res]
-----Original Message-----
From: Greg Quinn [mailto:greg@i...]
Sent: Thursday, August 22, 2002 3:17 AM
To: ASP+
Subject: CONFIRMED: Re: Viewstate not working for listboxes...
What someone pointed out to me is that because I am using a client side
script to modify the listboxes, the viewstate is not being updated, and thus
I should not use the viewstate.
So I have tried disabling the viewstate, but when it comes submitting the
values to my function, it reverts back to what was in the viewstate still.
Please take a look at my code, note the source code for the .js file is
listed afterwards.
<%@ Import Namespace = "System.Data" %>
<%@ Import Namespace = "System.Data.SqlClient" %>
<%@ Page EnableViewState = False %>
<script language = "vb" runat = "server">
Sub Page_Load()
If NOT Page.IsPostBack Then
PopulateLists()
End If
End Sub
Sub PopulateLists()
' DataBind Left Menu
' We must first remove any leading and trailing commas so the
sharelist is
readable by SQL...
Dim objConnection as New
SqlConnection(ConfigurationSettings.AppSettings("connString"))
Dim SqlGetList, shareListString, shareListCut as String
Dim shareListStringLength as Integer
SqlGetList = "SELECT TOP 1 ShareList FROM
ContactsShareLookup
WHERE ContactID = " & Request.QueryString("ContactID")
Dim objCommand as New SqlCommand(SqlGetList, objConnection)
objConnection.Open
Dim objDataReaderGetList as SqlDataReader
objDataReaderGetList = objCommand.ExecuteReader()
If objDataReaderGetList.Read() = False Then
shareListString = "0"
Else
shareListString = objDataReaderGetList("shareList")
If Len(shareListString) <= 0 Then
shareListString = "0"
Else
shareListCut = Mid(shareListString, 1, 1)
if Instr(1, shareListCut, ",") Then
shareListStringLength = Len(shareListString)
shareListString = Mid(shareListString, 2,
shareListStringLength - 1)
end if
End If
End If
objDataReaderGetList.Close()
objConnection.Close()
' Bind Left List
Dim SqlBindLeftList as String
SqlBindLeftList = "Select Users_UserID, (Users_Fname + char(32) +
Users_LName) as ExprJoinedName From Users WHERE Users_UserID <> " &
Session("UserID") & " AND Users_UserID NOT IN (" & shareListString & ")
ORDER BY Users_Fname"
objCommand = New SqlCommand(SqlBindLeftList, objConnection)
objConnection.Open
Dim objDataReaderBindLeftList as SqlDataReader
objDataReaderBindLeftList = objCommand.ExecuteReader()
list1.DataSource = objDataReaderBindLeftList
list1.DataBind()
objDataReaderBindLeftList.Close()
objConnection.Close()
' Bind Right List
Dim SqlBindRightList as String
SqlBindRightList = "Select Users_UserID, (Users_Fname + char(32) +
Users_LName) as ExprJoinedName From Users WHERE Users_UserID <> " &
Session("UserID") & " AND Users_UserID IN (" & shareListString & ") ORDER BY
Users_Fname"
objCommand = New SqlCommand(SqlBindRightList, objConnection)
objConnection.Open
Dim objDataReaderBindRightList as SqlDataReader
objDataReaderBindRightList = objCommand.ExecuteReader()
list2.DataSource = objDataReaderBindRightList
list2.DataBind()
objDataReaderBindRightList.Close()
objConnection.Close()
End Sub
Sub UpdateShare(Sender as Object, E as EventArgs)
' Update share list for contact
Dim objConnection = New
SQLConnection(ConfigurationSettings.AppSettings("connString"))
' First delete existing record
Dim strSQLDeleteExistingShare as String
strSQLDeleteExistingShare = "Delete From ContactsShareLookup
WHERE
ContactID = " & Request.QueryString("ContactID") & " AND UserID = " &
Session("UserID")
Dim myCommandShareDelete as New
SQLCommand(strSQLDeleteExistingShare,
objConnection)
myCommandShareDelete.Connection.Open()
myCommandShareDelete.ExecuteNonQuery()
myCommandShareDelete.Connection.Close()
' Add new share information to ContactsShareLookup
Dim newIDConstructor as new NextIDClass
Dim newShareID as Integer
newShareID
newIDConstructor.Get_Next_ID("ContactsShareLookup",
"ContactsShareID")
Dim shareString as String
Dim validItems as Integer
For validItems = 0 to list2.Items.Count() - 1
shareString += "," & list2.items(validItems).Value
Next
Dim strSQLInsertShare as String
strSQLInsertShare = "INSERT INTO ContactsShareLookup
(ContactsShareID,
UserID, ContactID, ShareList) VALUES "
strSQLInsertShare += "(" & newShareID & ","
strSQLInsertShare += "" & Session("UserID") & ","
strSQLInsertShare += "" & Request.QueryString("ContactID") &
","
strSQLInsertShare += "'" & shareString & "')"
Dim myCommandShareInsert as New
SQLCommand(strSQLInsertShare,
objConnection)
myCommandShareInsert.Connection.Open()
myCommandShareInsert.ExecuteNonQuery()
myCommandShareInsert.Connection.Close()
lblMessage.Text = shareString
End Sub
</script>
<HEAD>
<title>Officium</title>
<SCRIPT LANGUAGE="JavaScript" src = "../scripts/boxes.js"></script>
<link href="../include/forms.css" rel="stylesheet" type="text/css">
</HEAD>
<BODY bgcolor="#FFFFFF">
<asp:label id = "lblMessage" runat = "server" />
<form id="shareForm" runat = "server">
<table>
<tr>
<td colspan="3">Select the users to share this item with...</td>
</tr>
<tr>
<td> </td>
<td align="center" valign="middle"> </td>
<td> </td>
</tr>
<tr>
<td>
<asp:listbox enableViewState = "false" id = "list1" Style
"width:200px;height:350px;" DataValueField = "Users_UserID" DataTextField
"ExprJoinedName" cssStyle = "width : 150px" selectionMode = "multiple" runat
= "server" />
</td>
<td align="center" valign="middle">
<input type="button" onClick="move(this.form.list2,this.form.list1)"
value="<<">
<input type="button" onClick="move(this.form.list1,this.form.list2)"
value=">>">
</td>
<td>
<asp:listbox enableViewState = "false" id = "list2" Style
"width:200px;height:350px;" DataValueField = "Users_UserID" DataTextField
"ExprJoinedName" cssStyle = "width : 150px" selectionMode = "multiple" runat
= "server" />
</td>
</tr>
<tr>
<td> </td>
<td align="center" valign="middle">
<asp:button id = "updateBut" Text = "Save" onClick = "UpdateShare"
runat = "server" />
</td>
<td> </td>
</tr>
</table>
</form>
</body>
Here is the source for boxes.js
-------------------------------
function move(fbox, tbox) {
var arrFbox = new Array();
var arrTbox = new Array();
var arrLookup = new Array();
var i;
for (i = 0; i < tbox.options.length; i++) {
arrLookup[tbox.options[i].text] = tbox.options[i].value;
arrTbox[i] = tbox.options[i].text;
}
var fLength = 0;
var tLength = arrTbox.length;
for(i = 0; i < fbox.options.length; i++) {
arrLookup[fbox.options[i].text] = fbox.options[i].value;
if (fbox.options[i].selected && fbox.options[i].value != "") {
arrTbox[tLength] = fbox.options[i].text;
tLength++;
}
else {
arrFbox[fLength] = fbox.options[i].text;
fLength++;
}
}
arrFbox.sort();
arrTbox.sort();
fbox.length = 0;
tbox.length = 0;
var c;
for(c = 0; c < arrFbox.length; c++) {
var no = new Option();
no.value = arrLookup[arrFbox[c]];
no.text = arrFbox[c];
fbox[c] = no;
}
for(c = 0; c < arrTbox.length; c++) {
var no = new Option();
no.value = arrLookup[arrTbox[c]];
no.text = arrTbox[c];
tbox[c] = no;
}
}
-----Original Message-----
From: Sampath, Ramanujam (Cognizant) [mailto:SRamanuj@c...]
Sent: Tuesday, August 20, 2002 1:12 AM
To: ASP+
Subject: [aspx] Re: Viewstate not working for listboxes...
Well greg... can u post the code u are using in the whole of the page... Let
me check it....
cheers
S.Ramanujam
Programmer Analyst
38 & 39 Whites Road,
WCB - Whites Road Circular Building
Royapettah, Chennai - 600014
Ph : +xx xx xxx xxxx Extn 5113 [Off]
: +xx xx xxx xxxx [Res]
-----Original Message-----
From: Greg Quinn [mailto:greg@i...]
Sent: Tuesday, August 20, 2002 10:34 PM
To: ASP+
Subject: [aspx] Re: Viewstate not working for listboxes...
I have a;ready taken into account everything you have said, and yes I have
even explicitly enabled viewstate in the listbox tag, but still have the
same problem.
Please can someone help me with this!
Greg
-----Original Message-----
From: Ramanujam [mailto:sramanuj@c...]
Sent: Tuesday, August 20, 2002 8:21 AM
To: ASP+
Subject: [aspx] Re: Viewstate not working for listboxes...
Well If did u check the viewstate property of the ListBox... see if thats
true.... Only then the values are maintained. and one more is that
postback property of the ListBox will only post to server on any click or
any code in server side... and they are not supposed to maintain any
values....
This should keep u going. In case probelem still exists.. mail me
cheers
S.Ramanujam
Programmer Analyst
38 & 39 Whites Road,
WCB - Whites Road Circular Building
Royapettah, Chennai - 600014
Ph : +xx xx xxx xxxx Extn 5113 [Off]
: +xx xx xxx xxxx [Res]
> I have two listbox controls on a page that are databound when the page
loads
the first time, if the page is posted back, the controls are not rebound
again because the viewstate should keep the listbox information.
Well this is not happening, when I call a server-side function to read the
items sitting in the listbox, the listboxes reset to their original values,
even though I have checked for a postback.
What is happening here? this doesn't make sense...
Greg
---
ASP.NET 1.0 Namespace Reference with C#
http://www.wrox.com/acon11.asp?ISBN=1861007442
ASP.NET 1.0 Namespace Reference with VB.NET
http://www.wrox.com/acon11.asp?ISBN=1861007450
These books are a complete reference to the ASP.NET namespaces
for developers who are already familiar with using ASP.NET.
There is no trivial introductory material or useless .NET
hype and the presentation of the namespaces, in an easy-to use
alphabetical order ensures a user-friendly reference format.
We provide in-depth coverage of all the major ASP.NET classes,
giving you those real-world tips that the documentation doesn't
offer, and demonstrating complex techniques with simple
examples.
---
---
ASP.NET 1.0 Namespace Reference with C#
http://www.wrox.com/acon11.asp?ISBN=1861007442
ASP.NET 1.0 Namespace Reference with VB.NET
http://www.wrox.com/acon11.asp?ISBN=1861007450
These books are a complete reference to the ASP.NET namespaces
for developers who are already familiar with using ASP.NET.
There is no trivial introductory material or useless .NET
hype and the presentation of the namespaces, in an easy-to use
alphabetical order ensures a user-friendly reference format.
We provide in-depth coverage of all the major ASP.NET classes,
giving you those real-world tips that the documentation doesn't
offer, and demonstrating complex techniques with simple
examples.
---
---
ASP.NET 1.0 Namespace Reference with C#
http://www.wrox.com/acon11.asp?ISBN=1861007442
ASP.NET 1.0 Namespace Reference with VB.NET
http://www.wrox.com/acon11.asp?ISBN=1861007450
These books are a complete reference to the ASP.NET namespaces
for developers who are already familiar with using ASP.NET.
There is no trivial introductory material or useless .NET
hype and the presentation of the namespaces, in an easy-to use
alphabetical order ensures a user-friendly reference format.
We provide in-depth coverage of all the major ASP.NET classes,
giving you those real-world tips that the documentation doesn't
offer, and demonstrating complex techniques with simple
examples.
---
---
ASP.NET 1.0 Namespace Reference with C#
http://www.wrox.com/acon11.asp?ISBN=1861007442
ASP.NET 1.0 Namespace Reference with VB.NET
http://www.wrox.com/acon11.asp?ISBN=1861007450
These books are a complete reference to the ASP.NET namespaces
for developers who are already familiar with using ASP.NET.
There is no trivial introductory material or useless .NET
hype and the presentation of the namespaces, in an easy-to use
alphabetical order ensures a user-friendly reference format.
We provide in-depth coverage of all the major ASP.NET classes,
giving you those real-world tips that the documentation doesn't
offer, and demonstrating complex techniques with simple
examples.
---
Message #2 by R MALY GBIPS MIS <maly@m...> on Wed, 21 Aug 2002 15:38:42 +0100
|
|
I have not followed this thread properly but ...
to prevent a page being reloaded on postback (thus resetting combo boxes
etc.) I wrap all of the page_load code in the following if statement
if not ispostback then
'combo box load stuff!
end if
-----Original Message-----
From: Sampath, Ramanujam (Cognizant) [mailto:SRamanuj@c...]
Sent: 21 August 2002 15:28
To: ASP+
Subject: [aspx] RE: CONFIRMED: Re: Viewstate not working for
listboxes...
Well greg...
Now if u have removed the view state property then in the page_load
remove the postback property and call the populateList() each time the
pageload is called...
Now u have a problem.. Now u click on a item in a listboax and want
to post some values into the server depending upon which item is clicked
then u will face problem, because when it goes to server then the page_load
is called and the values are refreshed and so selectedItem will be null...
so to solve this write a client-Side script which will store the
SelectedItem in the List before it goes to the server and then oppulate it
when the postback to server happens....
keep me posted if the problem exists....
S.Ramanujam
Programmer Analyst
38 & 39 Whites Road,
WCB - Whites Road Circular Building
Royapettah, Chennai - 600014
Ph : +xx xx xxx xxxx Extn 5113 [Off]
: +xx xx xxx xxxx [Res]
-----Original Message-----
From: Greg Quinn [mailto:greg@i...]
Sent: Thursday, August 22, 2002 3:17 AM
To: ASP+
Subject: CONFIRMED: Re: Viewstate not working for listboxes...
What someone pointed out to me is that because I am using a client side
script to modify the listboxes, the viewstate is not being updated, and thus
I should not use the viewstate.
So I have tried disabling the viewstate, but when it comes submitting the
values to my function, it reverts back to what was in the viewstate still.
Please take a look at my code, note the source code for the .js file is
listed afterwards.
<%@ Import Namespace = "System.Data" %>
<%@ Import Namespace = "System.Data.SqlClient" %>
<%@ Page EnableViewState = False %>
<script language = "vb" runat = "server">
Sub Page_Load()
If NOT Page.IsPostBack Then
PopulateLists()
End If
End Sub
Sub PopulateLists()
' DataBind Left Menu
' We must first remove any leading and trailing commas so the
sharelist is
readable by SQL...
Dim objConnection as New
SqlConnection(ConfigurationSettings.AppSettings("connString"))
Dim SqlGetList, shareListString, shareListCut as String
Dim shareListStringLength as Integer
SqlGetList = "SELECT TOP 1 ShareList FROM
ContactsShareLookup
WHERE ContactID = " & Request.QueryString("ContactID")
Dim objCommand as New SqlCommand(SqlGetList, objConnection)
objConnection.Open
Dim objDataReaderGetList as SqlDataReader
objDataReaderGetList = objCommand.ExecuteReader()
If objDataReaderGetList.Read() = False Then
shareListString = "0"
Else
shareListString = objDataReaderGetList("shareList")
If Len(shareListString) <= 0 Then
shareListString = "0"
Else
shareListCut = Mid(shareListString, 1, 1)
if Instr(1, shareListCut, ",") Then
shareListStringLength = Len(shareListString)
shareListString = Mid(shareListString, 2,
shareListStringLength - 1)
end if
End If
End If
objDataReaderGetList.Close()
objConnection.Close()
' Bind Left List
Dim SqlBindLeftList as String
SqlBindLeftList = "Select Users_UserID, (Users_Fname + char(32) +
Users_LName) as ExprJoinedName From Users WHERE Users_UserID <> " &
Session("UserID") & " AND Users_UserID NOT IN (" & shareListString & ")
ORDER BY Users_Fname"
objCommand = New SqlCommand(SqlBindLeftList, objConnection)
objConnection.Open
Dim objDataReaderBindLeftList as SqlDataReader
objDataReaderBindLeftList = objCommand.ExecuteReader()
list1.DataSource = objDataReaderBindLeftList
list1.DataBind()
objDataReaderBindLeftList.Close()
objConnection.Close()
' Bind Right List
Dim SqlBindRightList as String
SqlBindRightList = "Select Users_UserID, (Users_Fname + char(32) +
Users_LName) as ExprJoinedName From Users WHERE Users_UserID <> " &
Session("UserID") & " AND Users_UserID IN (" & shareListString & ") ORDER BY
Users_Fname"
objCommand = New SqlCommand(SqlBindRightList, objConnection)
objConnection.Open
Dim objDataReaderBindRightList as SqlDataReader
objDataReaderBindRightList = objCommand.ExecuteReader()
list2.DataSource = objDataReaderBindRightList
list2.DataBind()
objDataReaderBindRightList.Close()
objConnection.Close()
End Sub
Sub UpdateShare(Sender as Object, E as EventArgs)
' Update share list for contact
Dim objConnection = New
SQLConnection(ConfigurationSettings.AppSettings("connString"))
' First delete existing record
Dim strSQLDeleteExistingShare as String
strSQLDeleteExistingShare = "Delete From ContactsShareLookup
WHERE
ContactID = " & Request.QueryString("ContactID") & " AND UserID = " &
Session("UserID")
Dim myCommandShareDelete as New
SQLCommand(strSQLDeleteExistingShare,
objConnection)
myCommandShareDelete.Connection.Open()
myCommandShareDelete.ExecuteNonQuery()
myCommandShareDelete.Connection.Close()
' Add new share information to ContactsShareLookup
Dim newIDConstructor as new NextIDClass
Dim newShareID as Integer
newShareID
newIDConstructor.Get_Next_ID("ContactsShareLookup",
"ContactsShareID")
Dim shareString as String
Dim validItems as Integer
For validItems = 0 to list2.Items.Count() - 1
shareString += "," & list2.items(validItems).Value
Next
Dim strSQLInsertShare as String
strSQLInsertShare = "INSERT INTO ContactsShareLookup
(ContactsShareID,
UserID, ContactID, ShareList) VALUES "
strSQLInsertShare += "(" & newShareID & ","
strSQLInsertShare += "" & Session("UserID") & ","
strSQLInsertShare += "" & Request.QueryString("ContactID") &
","
strSQLInsertShare += "'" & shareString & "')"
Dim myCommandShareInsert as New
SQLCommand(strSQLInsertShare,
objConnection)
myCommandShareInsert.Connection.Open()
myCommandShareInsert.ExecuteNonQuery()
myCommandShareInsert.Connection.Close()
lblMessage.Text = shareString
End Sub
</script>
<HEAD>
<title>Officium</title>
<SCRIPT LANGUAGE="JavaScript" src = "../scripts/boxes.js"></script>
<link href="../include/forms.css" rel="stylesheet" type="text/css">
</HEAD>
<BODY bgcolor="#FFFFFF">
<asp:label id = "lblMessage" runat = "server" />
<form id="shareForm" runat = "server">
<table>
<tr>
<td colspan="3">Select the users to share this item with...</td>
</tr>
<tr>
<td> </td>
<td align="center" valign="middle"> </td>
<td> </td>
</tr>
<tr>
<td>
<asp:listbox enableViewState = "false" id = "list1" Style
"width:200px;height:350px;" DataValueField = "Users_UserID" DataTextField
"ExprJoinedName" cssStyle = "width : 150px" selectionMode = "multiple" runat
= "server" />
</td>
<td align="center" valign="middle">
<input type="button" onClick="move(this.form.list2,this.form.list1)"
value="<<">
<input type="button" onClick="move(this.form.list1,this.form.list2)"
value=">>">
</td>
<td>
<asp:listbox enableViewState = "false" id = "list2" Style
"width:200px;height:350px;" DataValueField = "Users_UserID" DataTextField
"ExprJoinedName" cssStyle = "width : 150px" selectionMode = "multiple" runat
= "server" />
</td>
</tr>
<tr>
<td> </td>
<td align="center" valign="middle">
<asp:button id = "updateBut" Text = "Save" onClick = "UpdateShare"
runat = "server" />
</td>
<td> </td>
</tr>
</table>
</form>
</body>
Here is the source for boxes.js
-------------------------------
function move(fbox, tbox) {
var arrFbox = new Array();
var arrTbox = new Array();
var arrLookup = new Array();
var i;
for (i = 0; i < tbox.options.length; i++) {
arrLookup[tbox.options[i].text] = tbox.options[i].value;
arrTbox[i] = tbox.options[i].text;
}
var fLength = 0;
var tLength = arrTbox.length;
for(i = 0; i < fbox.options.length; i++) {
arrLookup[fbox.options[i].text] = fbox.options[i].value;
if (fbox.options[i].selected && fbox.options[i].value != "") {
arrTbox[tLength] = fbox.options[i].text;
tLength++;
}
else {
arrFbox[fLength] = fbox.options[i].text;
fLength++;
}
}
arrFbox.sort();
arrTbox.sort();
fbox.length = 0;
tbox.length = 0;
var c;
for(c = 0; c < arrFbox.length; c++) {
var no = new Option();
no.value = arrLookup[arrFbox[c]];
no.text = arrFbox[c];
fbox[c] = no;
}
for(c = 0; c < arrTbox.length; c++) {
var no = new Option();
no.value = arrLookup[arrTbox[c]];
no.text = arrTbox[c];
tbox[c] = no;
}
}
-----Original Message-----
From: Sampath, Ramanujam (Cognizant) [mailto:SRamanuj@c...]
Sent: Tuesday, August 20, 2002 1:12 AM
To: ASP+
Subject: [aspx] Re: Viewstate not working for listboxes...
Well greg... can u post the code u are using in the whole of the page... Let
me check it....
cheers
S.Ramanujam
Programmer Analyst
38 & 39 Whites Road,
WCB - Whites Road Circular Building
Royapettah, Chennai - 600014
Ph : +xx xx xxx xxxx Extn 5113 [Off]
: +xx xx xxx xxxx [Res]
-----Original Message-----
From: Greg Quinn [mailto:greg@i...]
Sent: Tuesday, August 20, 2002 10:34 PM
To: ASP+
Subject: [aspx] Re: Viewstate not working for listboxes...
I have a;ready taken into account everything you have said, and yes I have
even explicitly enabled viewstate in the listbox tag, but still have the
same problem.
Please can someone help me with this!
Greg
-----Original Message-----
From: Ramanujam [mailto:sramanuj@c...]
Sent: Tuesday, August 20, 2002 8:21 AM
To: ASP+
Subject: [aspx] Re: Viewstate not working for listboxes...
Well If did u check the viewstate property of the ListBox... see if thats
true.... Only then the values are maintained. and one more is that
postback property of the ListBox will only post to server on any click or
any code in server side... and they are not supposed to maintain any
values....
This should keep u going. In case probelem still exists.. mail me
cheers
S.Ramanujam
Programmer Analyst
38 & 39 Whites Road,
WCB - Whites Road Circular Building
Royapettah, Chennai - 600014
Ph : +xx xx xxx xxxx Extn 5113 [Off]
: +xx xx xxx xxxx [Res]
> I have two listbox controls on a page that are databound when the page
loads
the first time, if the page is posted back, the controls are not rebound
again because the viewstate should keep the listbox information.
Well this is not happening, when I call a server-side function to read the
items sitting in the listbox, the listboxes reset to their original values,
even though I have checked for a postback.
What is happening here? this doesn't make sense...
Greg
---
ASP.NET 1.0 Namespace Reference with C#
http://www.wrox.com/acon11.asp?ISBN=1861007442
ASP.NET 1.0 Namespace Reference with VB.NET
http://www.wrox.com/acon11.asp?ISBN=1861007450
These books are a complete reference to the ASP.NET namespaces
for developers who are already familiar with using ASP.NET.
There is no trivial introductory material or useless .NET
hype and the presentation of the namespaces, in an easy-to use
alphabetical order ensures a user-friendly reference format.
We provide in-depth coverage of all the major ASP.NET classes,
giving you those real-world tips that the documentation doesn't
offer, and demonstrating complex techniques with simple
examples.
---
---
ASP.NET 1.0 Namespace Reference with C#
http://www.wrox.com/acon11.asp?ISBN=1861007442
ASP.NET 1.0 Namespace Reference with VB.NET
http://www.wrox.com/acon11.asp?ISBN=1861007450
These books are a complete reference to the ASP.NET namespaces
for developers who are already familiar with using ASP.NET.
There is no trivial introductory material or useless .NET
hype and the presentation of the namespaces, in an easy-to use
alphabetical order ensures a user-friendly reference format.
We provide in-depth coverage of all the major ASP.NET classes,
giving you those real-world tips that the documentation doesn't
offer, and demonstrating complex techniques with simple
examples.
---
---
ASP.NET 1.0 Namespace Reference with C#
http://www.wrox.com/acon11.asp?ISBN=1861007442
ASP.NET 1.0 Namespace Reference with VB.NET
http://www.wrox.com/acon11.asp?ISBN=1861007450
These books are a complete reference to the ASP.NET namespaces
for developers who are already familiar with using ASP.NET.
There is no trivial introductory material or useless .NET
hype and the presentation of the namespaces, in an easy-to use
alphabetical order ensures a user-friendly reference format.
We provide in-depth coverage of all the major ASP.NET classes,
giving you those real-world tips that the documentation doesn't
offer, and demonstrating complex techniques with simple
examples.
---
---
ASP.NET 1.0 Namespace Reference with C#
http://www.wrox.com/acon11.asp?ISBN=1861007442
ASP.NET 1.0 Namespace Reference with VB.NET
http://www.wrox.com/acon11.asp?ISBN=1861007450
These books are a complete reference to the ASP.NET namespaces
for developers who are already familiar with using ASP.NET.
There is no trivial introductory material or useless .NET
hype and the presentation of the namespaces, in an easy-to use
alphabetical order ensures a user-friendly reference format.
We provide in-depth coverage of all the major ASP.NET classes,
giving you those real-world tips that the documentation doesn't
offer, and demonstrating complex techniques with simple
examples.
---
---
ASP.NET 1.0 Namespace Reference with C#
http://www.wrox.com/acon11.asp?ISBN=1861007442
ASP.NET 1.0 Namespace Reference with VB.NET
http://www.wrox.com/acon11.asp?ISBN=1861007450
These books are a complete reference to the ASP.NET namespaces
for developers who are already familiar with using ASP.NET.
There is no trivial introductory material or useless .NET
hype and the presentation of the namespaces, in an easy-to use
alphabetical order ensures a user-friendly reference format.
We provide in-depth coverage of all the major ASP.NET classes,
giving you those real-world tips that the documentation doesn't
offer, and demonstrating complex techniques with simple
examples.
---
Message #3 by "Greg Quinn" <greg@i...> on Wed, 21 Aug 2002 17:06:07 -0700
|
|
Writing a client-side script to store which items are selected seems
pointless, since the listbox on the right contains the selected items
already. Basically what I need to do now is find out a way to post the
selected items to my UPDATE function before the page refreshes the items in
the listbox.
So how do I do this?
Greg
-----Original Message-----
From: Sampath, Ramanujam (Cognizant) [mailto:SRamanuj@c...]
Sent: Wednesday, August 21, 2002 7:28 AM
To: ASP+
Subject: [aspx] RE: CONFIRMED: Re: Viewstate not working for
listboxes...
Well greg...
Now if u have removed the view state property then in the page_load
remove the postback property and call the populateList() each time the
pageload is called...
Now u have a problem.. Now u click on a item in a listboax and want
to post some values into the server depending upon which item is clicked
then u will face problem, because when it goes to server then the page_load
is called and the values are refreshed and so selectedItem will be null...
so to solve this write a client-Side script which will store the
SelectedItem in the List before it goes to the server and then oppulate it
when the postback to server happens....
keep me posted if the problem exists....
S.Ramanujam
Programmer Analyst
38 & 39 Whites Road,
WCB - Whites Road Circular Building
Royapettah, Chennai - 600014
Ph : +xx xx xxx xxxx Extn 5113 [Off]
: +xx xx xxx xxxx [Res]
-----Original Message-----
From: Greg Quinn [mailto:greg@i...]
Sent: Thursday, August 22, 2002 3:17 AM
To: ASP+
Subject: CONFIRMED: Re: Viewstate not working for listboxes...
What someone pointed out to me is that because I am using a client side
script to modify the listboxes, the viewstate is not being updated, and thus
I should not use the viewstate.
So I have tried disabling the viewstate, but when it comes submitting the
values to my function, it reverts back to what was in the viewstate still.
Please take a look at my code, note the source code for the .js file is
listed afterwards.
<%@ Import Namespace = "System.Data" %>
<%@ Import Namespace = "System.Data.SqlClient" %>
<%@ Page EnableViewState = False %>
<script language = "vb" runat = "server">
Sub Page_Load()
If NOT Page.IsPostBack Then
PopulateLists()
End If
End Sub
Sub PopulateLists()
' DataBind Left Menu
' We must first remove any leading and trailing commas so the
sharelist is
readable by SQL...
Dim objConnection as New
SqlConnection(ConfigurationSettings.AppSettings("connString"))
Dim SqlGetList, shareListString, shareListCut as String
Dim shareListStringLength as Integer
SqlGetList = "SELECT TOP 1 ShareList FROM
ContactsShareLookup
WHERE ContactID = " & Request.QueryString("ContactID")
Dim objCommand as New SqlCommand(SqlGetList, objConnection)
objConnection.Open
Dim objDataReaderGetList as SqlDataReader
objDataReaderGetList = objCommand.ExecuteReader()
If objDataReaderGetList.Read() = False Then
shareListString = "0"
Else
shareListString = objDataReaderGetList("shareList")
If Len(shareListString) <= 0 Then
shareListString = "0"
Else
shareListCut = Mid(shareListString, 1, 1)
if Instr(1, shareListCut, ",") Then
shareListStringLength = Len(shareListString)
shareListString = Mid(shareListString, 2,
shareListStringLength - 1)
end if
End If
End If
objDataReaderGetList.Close()
objConnection.Close()
' Bind Left List
Dim SqlBindLeftList as String
SqlBindLeftList = "Select Users_UserID, (Users_Fname + char(32) +
Users_LName) as ExprJoinedName From Users WHERE Users_UserID <> " &
Session("UserID") & " AND Users_UserID NOT IN (" & shareListString & ")
ORDER BY Users_Fname"
objCommand = New SqlCommand(SqlBindLeftList, objConnection)
objConnection.Open
Dim objDataReaderBindLeftList as SqlDataReader
objDataReaderBindLeftList = objCommand.ExecuteReader()
list1.DataSource = objDataReaderBindLeftList
list1.DataBind()
objDataReaderBindLeftList.Close()
objConnection.Close()
' Bind Right List
Dim SqlBindRightList as String
SqlBindRightList = "Select Users_UserID, (Users_Fname + char(32) +
Users_LName) as ExprJoinedName From Users WHERE Users_UserID <> " &
Session("UserID") & " AND Users_UserID IN (" & shareListString & ") ORDER BY
Users_Fname"
objCommand = New SqlCommand(SqlBindRightList, objConnection)
objConnection.Open
Dim objDataReaderBindRightList as SqlDataReader
objDataReaderBindRightList = objCommand.ExecuteReader()
list2.DataSource = objDataReaderBindRightList
list2.DataBind()
objDataReaderBindRightList.Close()
objConnection.Close()
End Sub
Sub UpdateShare(Sender as Object, E as EventArgs)
' Update share list for contact
Dim objConnection = New
SQLConnection(ConfigurationSettings.AppSettings("connString"))
' First delete existing record
Dim strSQLDeleteExistingShare as String
strSQLDeleteExistingShare = "Delete From ContactsShareLookup
WHERE
ContactID = " & Request.QueryString("ContactID") & " AND UserID = " &
Session("UserID")
Dim myCommandShareDelete as New
SQLCommand(strSQLDeleteExistingShare,
objConnection)
myCommandShareDelete.Connection.Open()
myCommandShareDelete.ExecuteNonQuery()
myCommandShareDelete.Connection.Close()
' Add new share information to ContactsShareLookup
Dim newIDConstructor as new NextIDClass
Dim newShareID as Integer
newShareID
newIDConstructor.Get_Next_ID("ContactsShareLookup",
"ContactsShareID")
Dim shareString as String
Dim validItems as Integer
For validItems = 0 to list2.Items.Count() - 1
shareString += "," & list2.items(validItems).Value
Next
Dim strSQLInsertShare as String
strSQLInsertShare = "INSERT INTO ContactsShareLookup
(ContactsShareID,
UserID, ContactID, ShareList) VALUES "
strSQLInsertShare += "(" & newShareID & ","
strSQLInsertShare += "" & Session("UserID") & ","
strSQLInsertShare += "" & Request.QueryString("ContactID") &
","
strSQLInsertShare += "'" & shareString & "')"
Dim myCommandShareInsert as New
SQLCommand(strSQLInsertShare,
objConnection)
myCommandShareInsert.Connection.Open()
myCommandShareInsert.ExecuteNonQuery()
myCommandShareInsert.Connection.Close()
lblMessage.Text = shareString
End Sub
</script>
<HEAD>
<title>Officium</title>
<SCRIPT LANGUAGE="JavaScript" src = "../scripts/boxes.js"></script>
<link href="../include/forms.css" rel="stylesheet" type="text/css">
</HEAD>
<BODY bgcolor="#FFFFFF">
<asp:label id = "lblMessage" runat = "server" />
<form id="shareForm" runat = "server">
<table>
<tr>
<td colspan="3">Select the users to share this item with...</td>
</tr>
<tr>
<td> </td>
<td align="center" valign="middle"> </td>
<td> </td>
</tr>
<tr>
<td>
<asp:listbox enableViewState = "false" id = "list1" Style
"width:200px;height:350px;" DataValueField = "Users_UserID" DataTextField
"ExprJoinedName" cssStyle = "width : 150px" selectionMode = "multiple" runat
= "server" />
</td>
<td align="center" valign="middle">
<input type="button" onClick="move(this.form.list2,this.form.list1)"
value="<<">
<input type="button" onClick="move(this.form.list1,this.form.list2)"
value=">>">
</td>
<td>
<asp:listbox enableViewState = "false" id = "list2" Style
"width:200px;height:350px;" DataValueField = "Users_UserID" DataTextField
"ExprJoinedName" cssStyle = "width : 150px" selectionMode = "multiple" runat
= "server" />
</td>
</tr>
<tr>
<td> </td>
<td align="center" valign="middle">
<asp:button id = "updateBut" Text = "Save" onClick = "UpdateShare"
runat = "server" />
</td>
<td> </td>
</tr>
</table>
</form>
</body>
Here is the source for boxes.js
-------------------------------
function move(fbox, tbox) {
var arrFbox = new Array();
var arrTbox = new Array();
var arrLookup = new Array();
var i;
for (i = 0; i < tbox.options.length; i++) {
arrLookup[tbox.options[i].text] = tbox.options[i].value;
arrTbox[i] = tbox.options[i].text;
}
var fLength = 0;
var tLength = arrTbox.length;
for(i = 0; i < fbox.options.length; i++) {
arrLookup[fbox.options[i].text] = fbox.options[i].value;
if (fbox.options[i].selected && fbox.options[i].value != "") {
arrTbox[tLength] = fbox.options[i].text;
tLength++;
}
else {
arrFbox[fLength] = fbox.options[i].text;
fLength++;
}
}
arrFbox.sort();
arrTbox.sort();
fbox.length = 0;
tbox.length = 0;
var c;
for(c = 0; c < arrFbox.length; c++) {
var no = new Option();
no.value = arrLookup[arrFbox[c]];
no.text = arrFbox[c];
fbox[c] = no;
}
for(c = 0; c < arrTbox.length; c++) {
var no = new Option();
no.value = arrLookup[arrTbox[c]];
no.text = arrTbox[c];
tbox[c] = no;
}
}
-----Original Message-----
From: Sampath, Ramanujam (Cognizant) [mailto:SRamanuj@c...]
Sent: Tuesday, August 20, 2002 1:12 AM
To: ASP+
Subject: [aspx] Re: Viewstate not working for listboxes...
Well greg... can u post the code u are using in the whole of the page... Let
me check it....
cheers
S.Ramanujam
Programmer Analyst
38 & 39 Whites Road,
WCB - Whites Road Circular Building
Royapettah, Chennai - 600014
Ph : +xx xx xxx xxxx Extn 5113 [Off]
: +xx xx xxx xxxx [Res]
-----Original Message-----
From: Greg Quinn [mailto:greg@i...]
Sent: Tuesday, August 20, 2002 10:34 PM
To: ASP+
Subject: [aspx] Re: Viewstate not working for listboxes...
I have a;ready taken into account everything you have said, and yes I have
even explicitly enabled viewstate in the listbox tag, but still have the
same problem.
Please can someone help me with this!
Greg
-----Original Message-----
From: Ramanujam [mailto:sramanuj@c...]
Sent: Tuesday, August 20, 2002 8:21 AM
To: ASP+
Subject: [aspx] Re: Viewstate not working for listboxes...
Well If did u check the viewstate property of the ListBox... see if thats
true.... Only then the values are maintained. and one more is that
postback property of the ListBox will only post to server on any click or
any code in server side... and they are not supposed to maintain any
values....
This should keep u going. In case probelem still exists.. mail me
cheers
S.Ramanujam
Programmer Analyst
38 & 39 Whites Road,
WCB - Whites Road Circular Building
Royapettah, Chennai - 600014
Ph : +xx xx xxx xxxx Extn 5113 [Off]
: +xx xx xxx xxxx [Res]
> I have two listbox controls on a page that are databound when the page
loads
the first time, if the page is posted back, the controls are not rebound
again because the viewstate should keep the listbox information.
Well this is not happening, when I call a server-side function to read the
items sitting in the listbox, the listboxes reset to their original values,
even though I have checked for a postback.
What is happening here? this doesn't make sense...
Greg
---
ASP.NET 1.0 Namespace Reference with C#
http://www.wrox.com/acon11.asp?ISBN=1861007442
ASP.NET 1.0 Namespace Reference with VB.NET
http://www.wrox.com/acon11.asp?ISBN=1861007450
These books are a complete reference to the ASP.NET namespaces
for developers who are already familiar with using ASP.NET.
There is no trivial introductory material or useless .NET
hype and the presentation of the namespaces, in an easy-to use
alphabetical order ensures a user-friendly reference format.
We provide in-depth coverage of all the major ASP.NET classes,
giving you those real-world tips that the documentation doesn't
offer, and demonstrating complex techniques with simple
examples.
---
---
ASP.NET 1.0 Namespace Reference with C#
http://www.wrox.com/acon11.asp?ISBN=1861007442
ASP.NET 1.0 Namespace Reference with VB.NET
http://www.wrox.com/acon11.asp?ISBN=1861007450
These books are a complete reference to the ASP.NET namespaces
for developers who are already familiar with using ASP.NET.
There is no trivial introductory material or useless .NET
hype and the presentation of the namespaces, in an easy-to use
alphabetical order ensures a user-friendly reference format.
We provide in-depth coverage of all the major ASP.NET classes,
giving you those real-world tips that the documentation doesn't
offer, and demonstrating complex techniques with simple
examples.
---
---
ASP.NET 1.0 Namespace Reference with C#
http://www.wrox.com/acon11.asp?ISBN=1861007442
ASP.NET 1.0 Namespace Reference with VB.NET
http://www.wrox.com/acon11.asp?ISBN=1861007450
These books are a complete reference to the ASP.NET namespaces
for developers who are already familiar with using ASP.NET.
There is no trivial introductory material or useless .NET
hype and the presentation of the namespaces, in an easy-to use
alphabetical order ensures a user-friendly reference format.
We provide in-depth coverage of all the major ASP.NET classes,
giving you those real-world tips that the documentation doesn't
offer, and demonstrating complex techniques with simple
examples.
---
---
ASP.NET 1.0 Namespace Reference with C#
http://www.wrox.com/acon11.asp?ISBN=1861007442
ASP.NET 1.0 Namespace Reference with VB.NET
http://www.wrox.com/acon11.asp?ISBN=1861007450
These books are a complete reference to the ASP.NET namespaces
for developers who are already familiar with using ASP.NET.
There is no trivial introductory material or useless .NET
hype and the presentation of the namespaces, in an easy-to use
alphabetical order ensures a user-friendly reference format.
We provide in-depth coverage of all the major ASP.NET classes,
giving you those real-world tips that the documentation doesn't
offer, and demonstrating complex techniques with simple
examples.
---
---
ASP.NET 1.0 Namespace Reference with C#
http://www.wrox.com/acon11.asp?ISBN=1861007442
ASP.NET 1.0 Namespace Reference with VB.NET
http://www.wrox.com/acon11.asp?ISBN=1861007450
These books are a complete reference to the ASP.NET namespaces
for developers who are already familiar with using ASP.NET.
There is no trivial introductory material or useless .NET
hype and the presentation of the namespaces, in an easy-to use
alphabetical order ensures a user-friendly reference format.
We provide in-depth coverage of all the major ASP.NET classes,
giving you those real-world tips that the documentation doesn't
offer, and demonstrating complex techniques with simple
examples.
---
Message #4 by "Sampath, Ramanujam (Cognizant)" <SRamanuj@c...> on Thu, 22 Aug 2002 09:16:31 +0530
|
|
Well thats what i told u already.... If the ListBox on the right already
contains the selected items then even before u post to the server copy the
contents of the selected items (this part of the code should be a
client-side script...as this will be done first and then the post to the
server happens) i.e. the values of the listbox on the right and then store
it in a collection variable. Then after PostBack u can call the Update
function for which the values come from the Collection and not from the
ListBox. Keep me posted of any issues here...
cheers...
S.Ramanujam
Programmer Analyst
38 & 39 Whites Road,
WCB - Whites Road Circular Building
Royapettah, Chennai - 600014
Ph : +xx xx xxx xxxx Extn 5113 [Off]
: +xx xx xxx xxxx [Res]
-----Original Message-----
From: Greg Quinn [mailto:greg@i...]
Sent: Thursday, August 22, 2002 5:36 AM
To: ASP+
Subject: [aspx] RE: CONFIRMED: Re: Viewstate not working for
listboxes...
Writing a client-side script to store which items are selected seems
pointless, since the listbox on the right contains the selected items
already. Basically what I need to do now is find out a way to post the
selected items to my UPDATE function before the page refreshes the items in
the listbox.
So how do I do this?
Greg
-----Original Message-----
From: Sampath, Ramanujam (Cognizant) [mailto:SRamanuj@c...]
Sent: Wednesday, August 21, 2002 7:28 AM
To: ASP+
Subject: [aspx] RE: CONFIRMED: Re: Viewstate not working for
listboxes...
Well greg...
Now if u have removed the view state property then in the page_load
remove the postback property and call the populateList() each time the
pageload is called...
Now u have a problem.. Now u click on a item in a listboax and want
to post some values into the server depending upon which item is clicked
then u will face problem, because when it goes to server then the page_load
is called and the values are refreshed and so selectedItem will be null...
so to solve this write a client-Side script which will store the
SelectedItem in the List before it goes to the server and then oppulate it
when the postback to server happens....
keep me posted if the problem exists....
S.Ramanujam
Programmer Analyst
38 & 39 Whites Road,
WCB - Whites Road Circular Building
Royapettah, Chennai - 600014
Ph : +xx xx xxx xxxx Extn 5113 [Off]
: +xx xx xxx xxxx [Res]
-----Original Message-----
From: Greg Quinn [mailto:greg@i...]
Sent: Thursday, August 22, 2002 3:17 AM
To: ASP+
Subject: CONFIRMED: Re: Viewstate not working for listboxes...
What someone pointed out to me is that because I am using a client side
script to modify the listboxes, the viewstate is not being updated, and thus
I should not use the viewstate.
So I have tried disabling the viewstate, but when it comes submitting the
values to my function, it reverts back to what was in the viewstate still.
Please take a look at my code, note the source code for the .js file is
listed afterwards.
<%@ Import Namespace = "System.Data" %>
<%@ Import Namespace = "System.Data.SqlClient" %>
<%@ Page EnableViewState = False %>
<script language = "vb" runat = "server">
Sub Page_Load()
If NOT Page.IsPostBack Then
PopulateLists()
End If
End Sub
Sub PopulateLists()
' DataBind Left Menu
' We must first remove any leading and trailing commas so the
sharelist is
readable by SQL...
Dim objConnection as New
SqlConnection(ConfigurationSettings.AppSettings("connString"))
Dim SqlGetList, shareListString, shareListCut as String
Dim shareListStringLength as Integer
SqlGetList = "SELECT TOP 1 ShareList FROM
ContactsShareLookup
WHERE ContactID = " & Request.QueryString("ContactID")
Dim objCommand as New SqlCommand(SqlGetList, objConnection)
objConnection.Open
Dim objDataReaderGetList as SqlDataReader
objDataReaderGetList = objCommand.ExecuteReader()
If objDataReaderGetList.Read() = False Then
shareListString = "0"
Else
shareListString = objDataReaderGetList("shareList")
If Len(shareListString) <= 0 Then
shareListString = "0"
Else
shareListCut = Mid(shareListString, 1, 1)
if Instr(1, shareListCut, ",") Then
shareListStringLength = Len(shareListString)
shareListString = Mid(shareListString, 2,
shareListStringLength - 1)
end if
End If
End If
objDataReaderGetList.Close()
objConnection.Close()
' Bind Left List
Dim SqlBindLeftList as String
SqlBindLeftList = "Select Users_UserID, (Users_Fname + char(32) +
Users_LName) as ExprJoinedName From Users WHERE Users_UserID <> " &
Session("UserID") & " AND Users_UserID NOT IN (" & shareListString & ")
ORDER BY Users_Fname"
objCommand = New SqlCommand(SqlBindLeftList, objConnection)
objConnection.Open
Dim objDataReaderBindLeftList as SqlDataReader
objDataReaderBindLeftList = objCommand.ExecuteReader()
list1.DataSource = objDataReaderBindLeftList
list1.DataBind()
objDataReaderBindLeftList.Close()
objConnection.Close()
' Bind Right List
Dim SqlBindRightList as String
SqlBindRightList = "Select Users_UserID, (Users_Fname + char(32) +
Users_LName) as ExprJoinedName From Users WHERE Users_UserID <> " &
Session("UserID") & " AND Users_UserID IN (" & shareListString & ") ORDER BY
Users_Fname"
objCommand = New SqlCommand(SqlBindRightList, objConnection)
objConnection.Open
Dim objDataReaderBindRightList as SqlDataReader
objDataReaderBindRightList = objCommand.ExecuteReader()
list2.DataSource = objDataReaderBindRightList
list2.DataBind()
objDataReaderBindRightList.Close()
objConnection.Close()
End Sub
Sub UpdateShare(Sender as Object, E as EventArgs)
' Update share list for contact
Dim objConnection = New
SQLConnection(ConfigurationSettings.AppSettings("connString"))
' First delete existing record
Dim strSQLDeleteExistingShare as String
strSQLDeleteExistingShare = "Delete From ContactsShareLookup
WHERE
ContactID = " & Request.QueryString("ContactID") & " AND UserID = " &
Session("UserID")
Dim myCommandShareDelete as New
SQLCommand(strSQLDeleteExistingShare,
objConnection)
myCommandShareDelete.Connection.Open()
myCommandShareDelete.ExecuteNonQuery()
myCommandShareDelete.Connection.Close()
' Add new share information to ContactsShareLookup
Dim newIDConstructor as new NextIDClass
Dim newShareID as Integer
newShareID
newIDConstructor.Get_Next_ID("ContactsShareLookup",
"ContactsShareID")
Dim shareString as String
Dim validItems as Integer
For validItems = 0 to list2.Items.Count() - 1
shareString += "," & list2.items(validItems).Value
Next
Dim strSQLInsertShare as String
strSQLInsertShare = "INSERT INTO ContactsShareLookup
(ContactsShareID,
UserID, ContactID, ShareList) VALUES "
strSQLInsertShare += "(" & newShareID & ","
strSQLInsertShare += "" & Session("UserID") & ","
strSQLInsertShare += "" & Request.QueryString("ContactID") &
","
strSQLInsertShare += "'" & shareString & "')"
Dim myCommandShareInsert as New
SQLCommand(strSQLInsertShare,
objConnection)
myCommandShareInsert.Connection.Open()
myCommandShareInsert.ExecuteNonQuery()
myCommandShareInsert.Connection.Close()
lblMessage.Text = shareString
End Sub
</script>
<HEAD>
<title>Officium</title>
<SCRIPT LANGUAGE="JavaScript" src = "../scripts/boxes.js"></script>
<link href="../include/forms.css" rel="stylesheet" type="text/css">
</HEAD>
<BODY bgcolor="#FFFFFF">
<asp:label id = "lblMessage" runat = "server" />
<form id="shareForm" runat = "server">
<table>
<tr>
<td colspan="3">Select the users to share this item with...</td>
</tr>
<tr>
<td> </td>
<td align="center" valign="middle"> </td>
<td> </td>
</tr>
<tr>
<td>
<asp:listbox enableViewState = "false" id = "list1" Style
"width:200px;height:350px;" DataValueField = "Users_UserID" DataTextField
"ExprJoinedName" cssStyle = "width : 150px" selectionMode = "multiple" runat
= "server" />
</td>
<td align="center" valign="middle">
<input type="button" onClick="move(this.form.list2,this.form.list1)"
value="<<">
<input type="button" onClick="move(this.form.list1,this.form.list2)"
value=">>">
</td>
<td>
<asp:listbox enableViewState = "false" id = "list2" Style
"width:200px;height:350px;" DataValueField = "Users_UserID" DataTextField
"ExprJoinedName" cssStyle = "width : 150px" selectionMode = "multiple" runat
= "server" />
</td>
</tr>
<tr>
<td> </td>
<td align="center" valign="middle">
<asp:button id = "updateBut" Text = "Save" onClick = "UpdateShare"
runat = "server" />
</td>
<td> </td>
</tr>
</table>
</form>
</body>
Here is the source for boxes.js
-------------------------------
function move(fbox, tbox) {
var arrFbox = new Array();
var arrTbox = new Array();
var arrLookup = new Array();
var i;
for (i = 0; i < tbox.options.length; i++) {
arrLookup[tbox.options[i].text] = tbox.options[i].value;
arrTbox[i] = tbox.options[i].text;
}
var fLength = 0;
var tLength = arrTbox.length;
for(i = 0; i < fbox.options.length; i++) {
arrLookup[fbox.options[i].text] = fbox.options[i].value;
if (fbox.options[i].selected && fbox.options[i].value != "") {
arrTbox[tLength] = fbox.options[i].text;
tLength++;
}
else {
arrFbox[fLength] = fbox.options[i].text;
fLength++;
}
}
arrFbox.sort();
arrTbox.sort();
fbox.length = 0;
tbox.length = 0;
var c;
for(c = 0; c < arrFbox.length; c++) {
var no = new Option();
no.value = arrLookup[arrFbox[c]];
no.text = arrFbox[c];
fbox[c] = no;
}
for(c = 0; c < arrTbox.length; c++) {
var no = new Option();
no.value = arrLookup[arrTbox[c]];
no.text = arrTbox[c];
tbox[c] = no;
}
}
-----Original Message-----
From: Sampath, Ramanujam (Cognizant) [mailto:SRamanuj@c...]
Sent: Tuesday, August 20, 2002 1:12 AM
To: ASP+
Subject: [aspx] Re: Viewstate not working for listboxes...
Well greg... can u post the code u are using in the whole of the page... Let
me check it....
cheers
S.Ramanujam
Programmer Analyst
38 & 39 Whites Road,
WCB - Whites Road Circular Building
Royapettah, Chennai - 600014
Ph : +xx xx xxx xxxx Extn 5113 [Off]
: +xx xx xxx xxxx [Res]
-----Original Message-----
From: Greg Quinn [mailto:greg@i...]
Sent: Tuesday, August 20, 2002 10:34 PM
To: ASP+
Subject: [aspx] Re: Viewstate not working for listboxes...
I have a;ready taken into account everything you have said, and yes I have
even explicitly enabled viewstate in the listbox tag, but still have the
same problem.
Please can someone help me with this!
Greg
-----Original Message-----
From: Ramanujam [mailto:sramanuj@c...]
Sent: Tuesday, August 20, 2002 8:21 AM
To: ASP+
Subject: [aspx] Re: Viewstate not working for listboxes...
Well If did u check the viewstate property of the ListBox... see if thats
true.... Only then the values are maintained. and one more is that
postback property of the ListBox will only post to server on any click or
any code in server side... and they are not supposed to maintain any
values....
This should keep u going. In case probelem still exists.. mail me
cheers
S.Ramanujam
Programmer Analyst
38 & 39 Whites Road,
WCB - Whites Road Circular Building
Royapettah, Chennai - 600014
Ph : +xx xx xxx xxxx Extn 5113 [Off]
: +xx xx xxx xxxx [Res]
> I have two listbox controls on a page that are databound when the page
loads
the first time, if the page is posted back, the controls are not rebound
again because the viewstate should keep the listbox information.
Well this is not happening, when I call a server-side function to read the
items sitting in the listbox, the listboxes reset to their original values,
even though I have checked for a postback.
What is happening here? this doesn't make sense...
Greg
---
ASP.NET 1.0 Namespace Reference with C#
http://www.wrox.com/acon11.asp?ISBN=1861007442
ASP.NET 1.0 Namespace Reference with VB.NET
http://www.wrox.com/acon11.asp?ISBN=1861007450
These books are a complete reference to the ASP.NET namespaces
for developers who are already familiar with using ASP.NET.
There is no trivial introductory material or useless .NET
hype and the presentation of the namespaces, in an easy-to use
alphabetical order ensures a user-friendly reference format.
We provide in-depth coverage of all the major ASP.NET classes,
giving you those real-world tips that the documentation doesn't
offer, and demonstrating complex techniques with simple
examples.
---
---
ASP.NET 1.0 Namespace Reference with C#
http://www.wrox.com/acon11.asp?ISBN=1861007442
ASP.NET 1.0 Namespace Reference with VB.NET
http://www.wrox.com/acon11.asp?ISBN=1861007450
These books are a complete reference to the ASP.NET namespaces
for developers who are already familiar with using ASP.NET.
There is no trivial introductory material or useless .NET
hype and the presentation of the namespaces, in an easy-to use
alphabetical order ensures a user-friendly reference format.
We provide in-depth coverage of all the major ASP.NET classes,
giving you those real-world tips that the documentation doesn't
offer, and demonstrating complex techniques with simple
examples.
---
---
ASP.NET 1.0 Namespace Reference with C#
http://www.wrox.com/acon11.asp?ISBN=1861007442
ASP.NET 1.0 Namespace Reference with VB.NET
http://www.wrox.com/acon11.asp?ISBN=1861007450
These books are a complete reference to the ASP.NET namespaces
for developers who are already familiar with using ASP.NET.
There is no trivial introductory material or useless .NET
hype and the presentation of the namespaces, in an easy-to use
alphabetical order ensures a user-friendly reference format.
We provide in-depth coverage of all the major ASP.NET classes,
giving you those real-world tips that the documentation doesn't
offer, and demonstrating complex techniques with simple
examples.
---
---
ASP.NET 1.0 Namespace Reference with C#
http://www.wrox.com/acon11.asp?ISBN=1861007442
ASP.NET 1.0 Namespace Reference with VB.NET
http://www.wrox.com/acon11.asp?ISBN=1861007450
These books are a complete reference to the ASP.NET namespaces
for developers who are already familiar with using ASP.NET.
There is no trivial introductory material or useless .NET
hype and the presentation of the namespaces, in an easy-to use
alphabetical order ensures a user-friendly reference format.
We provide in-depth coverage of all the major ASP.NET classes,
giving you those real-world tips that the documentation doesn't
offer, and demonstrating complex techniques with simple
examples.
---
---
ASP.NET 1.0 Namespace Reference with C#
http://www.wrox.com/acon11.asp?ISBN=1861007442
ASP.NET 1.0 Namespace Reference with VB.NET
http://www.wrox.com/acon11.asp?ISBN=1861007450
These books are a complete reference to the ASP.NET namespaces
for developers who are already familiar with using ASP.NET.
There is no trivial introductory material or useless .NET
hype and the presentation of the namespaces, in an easy-to use
alphabetical order ensures a user-friendly reference format.
We provide in-depth coverage of all the major ASP.NET classes,
giving you those real-world tips that the documentation doesn't
offer, and demonstrating complex techniques with simple
examples.
---
---
ASP.NET 1.0 Namespace Reference with C#
http://www.wrox.com/acon11.asp?ISBN=1861007442
ASP.NET 1.0 Namespace Reference with VB.NET
http://www.wrox.com/acon11.asp?ISBN=1861007450
These books are a complete reference to the ASP.NET namespaces
for developers who are already familiar with using ASP.NET.
There is no trivial introductory material or useless .NET
hype and the presentation of the namespaces, in an easy-to use
alphabetical order ensures a user-friendly reference format.
We provide in-depth coverage of all the major ASP.NET classes,
giving you those real-world tips that the documentation doesn't
offer, and demonstrating complex techniques with simple
examples.
---
|
|
 |