|
Hello,
I'm dynamicly filling a table with checkboxes, doing this:
<br />
...<br />
CheckBox chkBox = new CheckBox();<br />
chkBox.ID = "chk" + i.ToString();<br />
chkBox.AutoPostBack=true;<br />
...<br />
As you can see I create Checkboxes with ID's like: chk0, chk1, chk2 etc.
When I select one (or more) checkboxes the page reloads as it should.
However, when I try to read the properties of the checkboxes:
<br />
for (int i = 0 ; i < ; i++)<br />
{<br />
CheckBox c = (CheckBox)FindControl("chk"+i.ToString());<br />
<br />
Response.Write(c.ID);
Response.Write(c.Checked);
<br />
}<br />
Somehow he doesn't store the checked-value (true)
When the page reloads (after selecting a checkbox) the checkbox keeps selected, as it shoulds.
Can anyone help me?
Greetingz,
Eric
|
|
|
|
|
My first thought was that you weren't checking for PostBack until this line...
Jaymz666 wrote:
When the page reloads (after selecting a checkbox) the checkbox keeps selected, as it shoulds.
Which events these code snippets in? It seems like you have an issue with them getting recreated before you check them.
Jeff Martin
My Blog
|
|
|
|
|
Here is my code:
private void Page_Load(object sender, System.EventArgs e)<br />
{<br />
strApp[0] = "Word";<br />
strApp[1] = "Excel";<br />
strApp[2] = "Calculator";<br />
strApp[3] = "Solitaire";<br />
strApp[4] = "Explorer";<br />
<br />
fillTable();
<br />
if (IsPostBack)<br />
{<br />
showCheckbox();<br />
}<br />
}
I also tried to put the FillTable() behind the !IsPostback but then he can't find any checkboxes at all. So I need to 'Fill the table' every postback.
The code to fill the table:
public void fillTable()<br />
{<br />
int numberOfApps = strApp.Length;<br />
<br />
for(int i=0 ; i < numberOfApps ; i++)<br />
{ <br />
TableRow tr = new TableRow();<br />
TableCell tc_box = new TableCell();<br />
TableCell tc_app = new TableCell(); <br />
<br />
CheckBox chkBox = new CheckBox();<br />
chkBox.ID = "chk" + i.ToString();<br />
chkBox.Text = "#"+i.ToString();<br />
chkBox.AutoPostBack=true;<br />
chkBox.EnableViewState=true;
<br />
tc_box.Controls.Add(chkBox);<br />
tc_app.Text =strApp[i];<br />
tr.Cells.Add(tc_box);<br />
tr.Cells.Add(tc_app);<br />
Table1.Rows.Add(tr);<br />
}<br />
}
Works nice . In this case (just for debuggin' sake) I've enabled AutoPostBack. So when I select one checkbox he postsback the page wich wil fire up the showCheckbox() function:
public void showCheckbox()<br />
{<br />
for (int i = 0 ; i < strApp.Length ; i++)<br />
{<br />
CheckBox c; <br />
<br />
c = (CheckBox)FindControl("chk"+i.ToString());<br />
<br />
if (c.Checked==true)<br />
{<br />
Response.Write(c.ID);<br />
Response.Write("Works!");<br />
}<br />
else<br />
{<br />
}<br />
}<br />
}
As you can see I loop through the checkboxes with id's like: chk0, chk1 etc. He finds them! While debugging I can retrieve the checkboxes ID's! But the checked-state is false while he still is checked (true) in the InternetExplorer window.
I think it's got something to do with the postback & refilling the table. As showed above the page puts, everytime the page reloads, new checkboxes in the table. Where he doesn't check wheter the previous boxes are checked or not. Should I use something like a Session-array to store the checkboxes in? If yes, how do I do that?
Greetingz,
Eric
|
|
|
|
|
It is definitely a post back issue. When you fill the table, you are creating all new checkboxes. Instead of having one function that checks all of them, could you change to use the CheckChanged event handler?
<br />
void CheckBox_CheckedChanged(object sender, EventArgs e)<br />
{<br />
CheckBox c = (CheckBox)sender;<br />
if (c.Checked)<br />
{<br />
Response.Write(c.ID);<br />
Response.Write("Works!");<br />
}<br />
}<br />
and add this to your checkbox setup...
<br />
CheckBox chkBox = new CheckBox();<br />
chkBox.ID = "chk" + i.ToString();<br />
chkBox.Text = "#" + i.ToString();<br />
chkBox.AutoPostBack = true;<br />
chkBox.EnableViewState = true;
chkBox.CheckedChanged += CheckBox_CheckedChanged;<br />
Jeff Martin
My Blog
|
|
|
|
|
hi everyone,
I am NOT a javascript programmer, but like to do some web development.
How can I do the same as yahoo does in its compose box's, that is by giving a "Add Bcc" button, and as you click it, a new Bcc textfield is added to the webpage.
thanks in advance
|
|
|
|
|
<code><Script>
function display()
{
frm.strImage.style.display="";
}
</script>
<body>
<form id="frm">
<input name="Button" type="button" value="click" onClick="display()">
<input style="display:none" name="strImage" maxlength="100" size="30" >
</form></code>
<italic>Work hard, Work effectively and a bit of luck is the key to success.
|
|
|
|
|
thanks "Yulianto AKA goodmast3r"
just one more thing, how can I edit the function display() so
that I am able to add a textfield whenever the button is clicked.
So that the user can get as many textfields as he wishes.
thanks again
|
|
|
|
|
Basically you have to create a table for that and when the button is clicked, it will add a row to the table.
To add a row:
<code>input_form[0] = '<input name="strName" type="text" id="strName" size="13" >';
var row = detail.insertRow();
var cell = row.insertCell();
cell.innerHTML = input_form[0];</code>
I haven't test it though.
<italic>Work hard, Work effectively and a bit of luck is the key to success.
|
|
|
|
|
Hi
I'm having these errors when on the user registration form i created
and it gives these below errors, how do i also do:
- username validation to ensure the database doesnt duplicate
- generate a random password
- set today's date into customer_created_dated field in table
- set customer_active to 'Yes'
The errors I got when submitting the below form is as follows:
System.Data.OleDb.OleDbException: Operation must use an updateable query.
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextE rrorHandling(Int32 hr)
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextF orSingleResult(tagDBPARAMS dbParams, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommandText( Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommand(Comm andBehavior behavior, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteReaderIntern al(CommandBehavior behavior, String method)
at System.Data.OleDb.OleDbCommand.ExecuteNonQuery()
at DreamweaverCtrls.DataSet.DoInit()
My Code is: (minus the other non relevant)
<%@ Page Language="VB" ContentType="text/html" %>
<%@ Register TagPrefix="MM" Namespace="DreamweaverCtrls" Assembly="DreamweaverCtrls,version=1.0.0.0,publicKeyToken=83 6f606ede05d46a,culture=neutral" %><mm:insert
runat="server"
commandtext='<%# "insert="" into="" customer_details="" (customer_address,="" customer_city,="" customer_company,="" customer_country,="" customer_dob,="" customer_email,="" customer_fax,="" customer_firstname,="" customer_gender,="" customer_hometelephone,="" customer_lastname,="" customer_mobile,="" customer_officephone,="" customer_password,="" customer_security,="" customer_state,="" customer_zip)="" values="" (?,="" ?,="" ?)"="" %="">'
ConnectionString='<%# System.Configuration.ConfigurationSettings.AppSett ings("MM_CONNECTION_STRING_connSoftwares") %>'
DatabaseType='<%# System.Configuration.ConfigurationSettings.AppSett ings("MM_CONNECTION_DATABASETYPE_connSoftwares") %>'
Expression='<%# Request.Form("MM_insert") = "UserRegistration" %>'
CreateDataSet="false"
SuccessURL='<%# "register_completed.aspx" %>'
Debug="true"
><parameters>
<parameter name="@customer_address" value="<%# IIf((Request.Form("customer_address") <> Nothing), Request.Form("customer_address"), "") %>" type="WChar">
<parameter name="@customer_city" value="<%# IIf((Request.Form("customer_city") <> Nothing), Request.Form("customer_city"), "") %>" type="WChar">
<parameter name="@customer_company" value="<%# IIf((Request.Form("customer_company") <> Nothing), Request.Form("customer_company"), "") %>" type="WChar">
<parameter name="@customer_country" value="<%# IIf((Request.Form("customer_country") <> Nothing), Request.Form("customer_country"), "") %>" type="WChar">
<parameter name="@customer_dob" value="<%# IIf((Request.Form("customer_dob") <> Nothing), Request.Form("customer_dob"), "") %>" type="Date">
<parameter name="@customer_email" value="<%# IIf((Request.Form("customer_email") <> Nothing), Request.Form("customer_email"), "") %>" type="WChar">
<parameter name="@customer_fax" value="<%# IIf((Request.Form("customer_fax") <> Nothing), Request.Form("customer_fax"), "") %>" type="WChar">
<parameter name="@customer_firstname" value="<%# IIf((Request.Form("customer_firstname") <> Nothing), Request.Form("customer_firstname"), "") %>" type="WChar">
<parameter name="@customer_gender" value="<%# IIf((Request.Form("customer_gender") <> Nothing), Request.Form("customer_gender"), "") %>" type="WChar">
<parameter name="@customer_hometelephone" value="<%# IIf((Request.Form("customer_hometelephone") <> Nothing), Request.Form("customer_hometelephone"), "") %>" type="WChar">
<parameter name="@customer_lastname" value="<%# IIf((Request.Form("customer_lastname") <> Nothing), Request.Form("customer_lastname"), "") %>" type="WChar">
<parameter name="@customer_mobile" value="<%# IIf((Request.Form("customer_mobile") <> Nothing), Request.Form("customer_mobile"), "") %>" type="WChar">
<parameter name="@customer_officephone" value="<%# IIf((Request.Form("customer_officephone") <> Nothing), Request.Form("customer_officephone"), "") %>" type="WChar">
<parameter name="@customer_password" value="<%# IIf((Request.Form("customer_password") <> Nothing), Request.Form("customer_password"), "") %>" type="WChar">
<parameter name="@customer_security" value="<%# IIf((Request.Form("customer_security") <> Nothing), Request.Form("customer_security"), "") %>" type="Integer">
<parameter name="@customer_state" value="<%# IIf((Request.Form("customer_state") <> Nothing), Request.Form("customer_state"), "") %>" type="WChar">
<parameter name="@customer_zip" value="<%# IIf((Request.Form("customer_zip") <> Nothing), Request.Form("customer_zip"), "") %>" type="WChar">
<mm:pagebind runat="server" postbackbind="true">
Registration Form
Registration Form (Users)
|
|
|
|
|
Hello,
I've developed a COM object which is using a CSocket object to connect to a server. I'm using this COM object from an ASP page.
The functionality is quite simple:
- enter a critical section
- create a socket and talk to a server
- exit critical section
Using the debug build of my COM object the execution is hanging when attempting to enter the critical section (probably not hanging but just waiting for the critical section to get released - which is strange because no other process/thread is in that critical section).
Using the release build of the COM object, the execution passes ok the critical section statement but it throws an exception when creating the CSocket object (oSocket.Create() function).
The exception message is "Out of memory".
I suppose here is because of some security restriction or something.
The same COM object is working fine (both debug and release builds) under IIS 5 (Windows 2000) or IIS 5.1 (XP).
Any help would be greately approciated
Sorin
|
|
|
|
|
I already create the ASP script for the database and also set up the ODBC for the database, why my ASP still can't read the data from the database? Please help me!!!
This is the ASP code:
<form method = "POST" action="online_result.asp" onSubmit="validInput()">
<p align="center">ENTER FIRST NAME:
<input type="text" name="FirstName" size="20">
</p>
<p align="center">ENTER LAST NAME :
<input type="text" name="LastName" size="20">
</p>
<p align="center"> ENTER STUDENT ID:
<input type="password" name="StudentID" size="20">
</p>
<p align="center">
<input type="submit" value="Check In" name="Submit">
<input type="reset" value="Reset" name="Reset">
</p>
</form>
<%
Else
%>
<p align="center"><font face="Comic Sans MS" size="5">
<strong>YOUR RESULT</strong></font>
</p>
<%
Dim SQLString
SQLString = "SELECT student.StudentID, student.FirstName, student.LastName, result.SubjectTaken, result.Grade FROM student, result WHERE student.StudentID = result.StudentID"
If Not Request.Form.Item("StudentID") = "All" Then
SQLString = SQLString & " WHERE result.StudentID=" & chr(39) & Request.Form.Item("StudentID") & chr(39)
End If
If Not Request.Form.Item("FirstName") = " " Then
SQLString = SQLString & " AND result.FirstName=" & chr(39) & Request.Form.Item("FirstName") & chr(39)
End If
If Not Request.Form.Item("LastName") = " " Then
SQLString = SQLString & " AND result.LastName=" & chr(39) & _Request.Form.Item("LastName") & chr(39)
End If
'Create an instance for the Connection Object
Set DatabaseConnection = Server.CreateObject("ADODB.Connection")
'Open Connection to onlineresult database
DatabaseConnection.Open "FILEDSN=Studentresult.dsn"
'Create an instance of the recordset object
Set ResultRecordSet = Server.CreateObject("ADODB.RecordSet")
'Open the onlineresult database and retrieve the data
ResultRecordSet.Open SQLString, DatabaseConnection
Set objResultFirstName = ResultRecordSet("FirstName")
Set objResultLastName = ResultRecordSet("LastName")
Set objResultStudentID = ResultRecordSet("StudentID")
Set objResultSubjectTaken = ResultRecordSet("SubjectTaken")
Set objResultGrade = ResultRecordSet("Grade")
If ResultRecordSet.EOF Then
%>
<p align = "center"><font face ="Arial Black" size="5">
<strong>Sorry. No Records match your search!!!</strong></font>
</p>
<%
Else
%>
<%
<p align = "left"><font face="Arial Narrow" size="3">
<strong>Name: </strong> Response.Write "&objFirstName&" "&objLastName&"
</font>
</p>
<p align = "left"><font face="Arial Narrow" size="3">
<strong>Student ID : </strong> Response.Write "&objStudentID&"
</font>
</p>
%>
<Table border ="2" cellspacing="0" cellpadding="2">
<tr><td>Subject Code</td><td>Grade</td></tr>
<%
Do Until ResultRecordSet.EOF
Response.Write "<tr valign="top"><td>"&objResultSubjectTaken&"</td>
<td>"&objResultGrade&"
ResultRecordSet.MoveNext
Loop
DatabaseConnection.Close
Response.Write "</table>"
End If
End If
%>
|
|
|
|
|
Do you get any errors ?
do your queries work fine when you run them in MS Access ?
|
|
|
|
|
Hello friends
I have the follow html page (do you can copy and save as test.htm, by example)
<div id="divOrigin"><br>
<STYLE> <!-- .Test1 { color: #0000FF; font-weight: bold } .Test2 { color:
#FF0000; font-weight: bold } --> </STYLE><br>
<span class='Test1'>Test1</span><br>
<span class='Test2'>Test2</span> <br>
</div><br>
<div id="divDestination"></div><br>
<SCRIPT type="text/javascript">
<!--
function CopyContents(div1, div2)
{
div2.innerHTML = div1.innerHTML;
}
someDiv = document.getElementById("divOrigin");
otherDiv = document.getElementById("divDestination");
CopyContents(someDiv,otherDiv);
alert(someDiv.innerHTML);
alert(otherDiv.innerHTML);
</SCRIPT>
Please, check the contents of divOrigin, and the 2 alertboxes in Internet Explorer and FireFox...
IE (Alert1):
<STYLE> <!-- .Test1 { color: #0000FF; font-weight: bold } .Test2 { color: <br />
#FF0000; font-weight: bold } --> </STYLE><br />
<span class='Test1'>Test1</span><br />
<span class='Test2'>Test2</span>
IE (Alert2), FireFox(Alert1) and FireFox(Alert2)
<span class='Test1'>Test1</span> <span class='Test2'>Test2</span>
I wish one EXACT COPY of contents from divOrigin to divDestination, but I know not how I can do it works in Firefox and IE... I need what all alerts show equals of IE(Alert1).
Someone can help me?
Loane
|
|
|
|
|
I am writing a web-form using HTML and Javascript. I need to populate another field using a selection of other part of the form. Is there a way to do it? My problem is user selects an option, can I use that data to populate another text box in the same form?
Thanks for your help!
Jamal
|
|
|
|
|
Hello
I m facing a problem in my site that when i click on menu which i build using Dreamweaver. Menu goes into back and combo control appear infront of that menu. Any body please guide me how i control this.
Tariq Mahmood
|
|
|
|
|
I have added the CWebBrowser control to my MFC program. I can Get/Set the URL, but was wondering if it is possible to get hold of some of the data being displayed on the page; e.g. tables elements and current Combo selection.
Don't know if this is the correct forum for this question,
Cheers,
Graham.
grahamfff
|
|
|
|
|
have a 3 tier (biz data and gui layers) web app.
Should I be destroying the BLL or DAL objects after I am none using them?
How come w3wp.exe on the server keeps growing as people use the web app?
Does the fact that none is destroying the objects when they use them have anything to do with it?
We recently moved to the QC box and I am very concerned with the mem usage of w3wp.exe going up as I am testing the site. I am the only user.
Thank you in advance for any advice.
Paixtis
|
|
|
|
|
Actually i am doing a program in JSFL(Flash Javascript).So i
posted the thread here and it's a basic problem.
Suppose,
string = 'welcome to moni\'s homepage'
var i = string.indexOf("\'");
var j = string.indexOf("\'",j);
valueOfString = string.substring(i+1, j);
now valueOfString is welcome to moni
but i need to return it as welcome to moni's homepage.
What should i do?Thanks
|
|
|
|
|
You need a replace function, not a substring function. Probably string.replace("\", "")
Jeff Martin
My Blog
|
|
|
|
|
Monisankar wrote:
Actually i am doing a program in JSFL(Flash Javascript).So i
posted the thread here and it's a basic problem.
Suppose,
string = 'welcome to moni\'s homepage'
var i = string.indexOf("\'");
var j = string.indexOf("\'",j);
valueOfString = string.substring(i+1, j);
now valueOfString is welcome to moni
but i need to return it as welcome to moni's homepage.
What should i do?Thanks
As said, in the previous reply to your question you either need a replace method, or you need to add on the end of the string to the current one.
Ie. valueOfString = string.substring(i+1,j) + string.substring(j+1,stringLength)
I don't know what the string length function in JSFL though...
_____________________
Don't take out the Magic Pen,
Don't draw on the Infinity Board
- Neil Young
|
|
|
|
|
Thanks to both of u.
Got it and solved.
Thanks
|
|
|
|
|
A few months ago, I found an article on making like a class with java script. It forgot the link. Any body knows this article? Thanks.
<italic>Work hard, Work effectively and a bit of luck is the key to success.
|
|
|
|
|
You mean this? [^](Use Javascript object like you do it in C#] [http://weblogs.asp.net]
Edbert
|
|
|
|
|
Hi guys,
I searched all over the web for a login script in JAVASCRIPT!! but all i could find is VBscripts. Can someone please help, i desperatly need a JS login script that links to an access database.
Thanks!
|
|
|
|
|
in my web page i put 3radio button one buuton for excel.2nd button for html and last one for pdf.so when user click on the button a save as dilog box will open with corresponding file format.for example if a user choose excel button then a save as dilog box will open with save as type *.xls.i also want to retrieve the full physical path where the user store the file.
how i'll do this in java script plz any body know help me.
with regards
swagatika
|
|
|
|
|