|
Thank you, Fred. I really appreciate your help! Actually, I am shocked that I was that close.
sduffield
|
|
|
|
|
|
hi. i have a simple page with some textboxes, a submit button and a client-side reset button.
1. for this first scenario, i fill the textboxes and the reset button works fine in case i click on it
2. for the second scenario, after i filled the form, i submit it and after the postback, since it's an aspnet page
i have the textboxes filled ... in case i click the reset button the textboxes will not be cleared, but it will be
reset to the previous values, because now the reset will 'think' that the original values are not the empty ones,
but the ones i have filled the form
note: i also set the enableviewstate=false to the textboxes
note: if i do a server.transfer then i have the textboxes cleared, but this is no option, since after the submit i show a message in the page, plus i don't want to postback a page just to clear the form elements
note: i reset the form elements with the following code:
1
2 function ResetForm()
3 {
4 var formId = <%= "'" + Form.ClientID + "'" %>;
5 document.forms[formId].reset();
6 }
7
someone may say to use a javascript code to look for the form elements i want to reset and set its values to empty, but again why? since i have a built-in reset method
so, as far as my understanding goes, form.reset, reset form fields to its original values, not necessarily empty values ... after the postback, the original form values will be the ones i had filled in, like in the second scenario example.
any tips on how to properly reset this form?
»»» KenA
|
|
|
|
|
It resets your values after the postback since the html returned has value="your value" for each field, so the reset uses these values (which are empty on the first request)...but anyway you already got that far.
Why are you using javascript for the reset in the first place? Why not use ?
Since the values are 'hard-coded' (in the html) upon a postback, javascript is your only option. Heres a simple function that should work:
<br />
function ResetForm()<br />
{<br />
var inputs = document.getElementsByTagName("input");<br />
for(var i = 0; i < inputs.length; i++)<br />
{<br />
inputs[i].value = "";<br />
}<br />
}<br />
I haven't tested the function and it will only reset input elements (ie not select).
|
|
|
|
|
badgrs wrote: Why are you using javascript for the reset in the first place? Why not use ?
hi ... the reason i'm not using the type="reset" is because i also call another js Page_ClientValidate(); in order to clear any eventual error msg previously displayed in case the user has done some bad format input, other than this i would use your idea.
badgrs wrote: Since the values are 'hard-coded' (in the html) upon a postback, javascript is your only option.
ow, that's what i was afraid of ... but if js is my only option, this leads to the following conclusion: for asp.net pages it's useless to call form.reset or the input type="reset" tag since it will only work before postbacks, plus i will also have to manually track all forms elements i'm eventually using in the webpage, not just input fields, but select fields, option, etc as well
what is important to notice is that the built-in form[].reset() goal is really to 'reset' form values to its original values and NOT to clear all form fields, unless the initial values are empty ones!!!
but then a doubt raises: isn't asp.net breaking the rules by maintaining form field values after a postback? one of the great things when asp.net brought was keeping form values after a postback, but now i can't use one of the most basic things in html???
»»» KenA
|
|
|
|
|
Ken.A wrote: pages it's useless to call form.reset or the input type="reset" tag since it will only work before postbacks, plus i will also have to manually track all forms elements i'm eventually using in the webpage, not just input fields, but select fields, option, etc as well
Check out the related thread in the message whose permalink is here: http://www.codeproject.com/script/comments/forums.asp?msg=2099807&forumid=1640#xx2099807xx[^]
Ken.A wrote: isn't asp.net breaking the rules by maintaining form field values after a postback?
ViewState has the advantage of resurrecting the form values after the roundtrip. Perhaps in your perspective, it is a double-edged sword.
|
|
|
|
|
badgrs wrote: Since the values are 'hard-coded' (in the html) upon a postback, javascript is your only option.
True.
badgrs wrote: function ResetForm()
{
var inputs = document.getElementsByTagName("input");
for(var i = 0; i < inputs.length; i++)
{
inputs[i].value = "";
}
}
Additionally, you may need to accomodate TEXTAREA tags. For Select tags, you can set selectedIndex to -1.
|
|
|
|
|
ok ... but your ResetForm() method is too generic ... it will reset all inputs in my webform, eg: type="submit", type"option", etc ... i just want to reset type="text" ... looping through all the input attributes until i find one with type="text" to clear its value ... hum, is there a better way?
»»» KenA
|
|
|
|
|
a better ResetForm method could be something like:
<br />
function ResetFormByTagName( tagName, hasValidators )<br />
{<br />
var arrTags = document.getElementsByTagName( tagName );<br />
for( var i=0; i<arrTags.length; i++ )<br />
{<br />
if( arrTags[i].type=="text" || arrTags[i].type=="password" )<br />
arrTags[i].value = "";<br />
<br />
}<br />
<br />
if( hasValidators==true )<br />
Page_ClientValidate();<br />
}<br />
»»» KenA
|
|
|
|
|
hey there
i use transparent canvas on my pics ,in order to use a fine background template i made
in mozilla everything is great (again) but in IE(6) i get a gray img bgrnd ,that covers up the page backround
i use fireworks 8 for image editing
Is there a body{} or html{} css rule that will solve this problem
thanks
(i hope i'm in the right message board for this)
P.
ninja coding
|
|
|
|
|
|
If you need something that will work on IE6 and IE7, check out the progid:DXImageTransform.Microsoft.gradient() filter. You can set both starting and ending colors to whatever you want the background to be, and use the alpha component of the color values to achieve transparency.
And yeah, there's an actual opacity() filter as well... but the results look awful.
----
Yes, but can you blame them for doing so if that's the only legal way they can hire programmers they want at the rate they can afford?-- Nish on sketchy hiring practices
|
|
|
|
|
Hello all
i am working with web site its style sheet does not give proper reuult in IE7 , Previously i was working with IE6 in which it works Properly.
(it works Proper in Opera, Netscap, Mozila PROBLEM is Only when i run that in IE7)
SP
--
Bugs can neither be created nor be removed from software by a developer. They can only be converted from one form to another. The total number of bugs in the software always remain constant.
|
|
|
|
|
Any particular style definition you would like to quote that is breaking in IE 7?
|
|
|
|
|
Hi,
I have a page that reads an image from another aspx-file. The image is generated on the fly using GDI+.
A javascript in the main page refreshes the image at a regular interval.
This works great in IE6, but in IE7 the image is only loaded the first time. If I refresh the page the image is loaded again, but only once.
To me, this is a cachingproblem in IE7...but I have no idea how to fix it.
Does anybody know how to fix this?
|
|
|
|
|
To the image URL, can you append each time a random digit or number? That would prevent IE from caching it thinking that it is a new request each time.
|
|
|
|
|
Thanks for the tip!
It works, but I still think there must be a function to disable or configure. Doesnt anybody else have a similar problem?
|
|
|
|
|
Hi guys.
I have managed to get some code for a for database connection.
Now, it runs well with no errors but doesnt display any values.Can anyone check and tell me where I went wrong.Its simply suppose to show values during run mode.
<%@ Import Namespace="System.Data.OleDb" %>
<%@LANGUAGE="VBSCRIPT" runat="Server" CODEPAGE="1252"%>
sub Page_Load
dim dbconn,sql,dbcomm,dbread
dbconn=New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;data source=" & server.mappath("/db/NWIND.mdb"))
dbconn.Open()
sql="SELECT * FROM Customers"
dbcomm=New OleDbCommand(sql,dbconn)
dbread=dbcomm.ExecuteReader()
Customers.DataSource=dbread
Customers.DataBind()
dbread.Close()
dbconn.Close()
end sub
<title>Companyname
<asp:datalist
id="customers"
runat="server"
cellpadding="2"
cellspacing="2"
borderstyle="inset"
backcolor="#e8e8e8"
width="100%"
headerstyle-font-name="verdana"
headerstyle-font-size="12pt"
headerstyle-horizontalalign="center"
headerstyle-font-bold="true"
itemstyle-backcolor="#778899"
itemstyle-forecolor="#ffffff"
footerstyle-font-size="9pt"
footerstyle-font-italic="true">
<headertemplate>
Customers Table
<itemtemplate>
<%#Container.DataItem("Company Name")%> in
<%#Container.DataItem("Address")%>, <%#Container.DataItem("City")%>
<footertemplate>
Source: Northwind Database
Please help guys
-- modified at 8:52 Monday 25th June, 2007
kagiso
|
|
|
|
|
is this code for your dropdown list if yes you have to add the following properties to your dropdownlist
ddlLanguage --> dropdownlist name
ddlLanguage.DataSource = ds.Tables(0)
ddlLanguage.DataTextField = "Column Which you want to show"
ddlLanguage.DataValueField = "Column Value to be assigned "
ddlLanguage.DataBind()
Thanks
Warm Regards
Prakash-B
|
|
|
|
|
well, at the moment Im still worried about the connection.I jus need to show the values without selecting anything.
After making sure that the values show, then I can change to select from a dropdown.
kagiso
|
|
|
|
|
i cannot understant about your problem clearly
Thanks
Warm Regards
Prakash-B
|
|
|
|
|
Ok, the code I posted is suppose to show values off a database straight onto a page during form load(when u run the page), so the problem is that I dont see any errors, and no values are shown either.
The table is called Customers.So the values should show automatically when i run the page, but they dont and has no errors either.
kagiso
|
|
|
|
|
check you have returned values from the database if no check with you query
Thanks
Warm Regards
Prakash-B
|
|
|
|
|
U are not clear.I dont understand u
kagiso
|
|
|
|
|
Ok.Here is the drill.
I have a code that runs.It establishes a connection with my NWIND database, then extract values from a table called Customers.This values are then displaye on my page.
All this happens during execution.
kagiso
|
|
|
|