Ask a Question related to ASP.NET General, Design and Development.
-
Robert Johnson #1
Need a few lines of code help, will pay!
I need to figure out how to go through all of the WebControls on a form,
find all the ones that are named with a "txt" prefix (ie txtFirstName), and
then retrieve the WebControl ID, Text (value), and Tab Index and put them
into a collection or array.
I have spent all day working on this and I just can't quite figure it out. I
would appreciate any help you can give. I will happily pay $50 to the first
person who can come up with a solution that works!!!
Thanks a bunch!
Robert Johnson
Robert Johnson Guest
-
Extra Blank Lines in Code
:frown; My wife uses Contribute 3 to do some edits and updates for a site that I use Dreamweaver 8 for. When I open a file in Dreamweaver that she... -
Blank Lines in program code
After editing the Home page in Contribute 2 many blank lines are inserted into the page source code. The size of the page keeps increasing... -
Maximum Lines of Code
:o All, I am having a peculiar problem with an <cfif> tag. I get an error message during the execution of the page that tells me the <cfif> tag... -
Why is there no error thrown in these 3 lines of code?
$MyVar=1; if (MyVar ==1){ $var2="abc"; } Notice I left out the "$" in the IF statement. No error. It drops into the statement and sets the... -
Combine separate lines of code into one.
Hi, I have some lingo that set an individual sprite height & width to 64. I need this to happen to 5 separte sprites. Currently my code is: ... -
Robert Johnson #2
Re: Need a few lines of code help, will pay!
Unfortunately, that doesn't quite work. Tab Index is not a property of
LiteralControl or ResourceBasedLiteralControl. As a result, I get the
following error: Public member 'TabIndex' on type
'ResourceBasedLiteralControl' not found.
It needs to use the WebControl instead of Control.
I am still still looking for a solution and am happy to pay for it! If you
(or anyone else) has a fix, I really need one!
Thanks,
Robert
"John Knoop" <john.k@home.se> wrote in message
news:Oxe5WMWWDHA.216@TK2MSFTNGP11.phx.gbl...them> Wouldn't something like this work?
>
> Dim x as object
>
> For each x in page.controls
> if left(x.id, 3) = "txt" then
> 'do something with x.text
> end if
> next x
>
> /john
>
> "Robert Johnson" <buttons@internetwebzone.com> wrote in message
> news:eb9t#WVWDHA.608@TK2MSFTNGP12.phx.gbl...> and> > I need to figure out how to go through all of the WebControls on a form,
> > find all the ones that are named with a "txt" prefix (ie txtFirstName),> > then retrieve the WebControl ID, Text (value), and Tab Index and putout.> > into a collection or array.
> >
> > I have spent all day working on this and I just can't quite figure it> I> first> > would appreciate any help you can give. I will happily pay $50 to the>> > person who can come up with a solution that works!!!
> >
> > Thanks a bunch!
> >
> > Robert Johnson
> >
> >
> >
>
Robert Johnson Guest
-
Natty Gur #3
Re: Need a few lines of code help, will pay!
Hi,
Here the code. I prefer to use types then text. Keep the mony ... :-)
1) Class to hold data :
class MyDat
{
public string Text;
public int TabIndex;
public MyDat(string inText,int inTabIndex)
{
Text = inText;
TabIndex = inTabIndex;
}
}
2) Form Load :
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
System.Collections.Hashtable oT = new
System.Collections.Hashtable();
HtmlForm theForm = (HtmlForm)this.FindControl("WebForm3");
GetTextBoxes(theForm,oT);
}
3) recursiv function :
private void GetTextBoxes(Control Father,System.Collections.Hashtable
oT)
{
for (int i = 0 ; i< Father.Controls.Count; i++)
{
if (Father.Controls[i] is TextBox)
{
MyDat oData = new MyDat(
((TextBox)Father.Controls[i]).Text,((TextBox)Father.Controls[i]).TabInde
x);
oT.Add(((TextBox)Father.Controls[i]).ID,oData);
}
if (Father.Controls.Count > 0)
{
GetTextBoxes(Father.Controls[i],oT);
}
}
}
Natty Gur, CTO
Dao2Com Ltd.
34th Elkalay st. Raanana
Israel , 43000
Phone Numbers:
Office: +972-(0)9-7740261
Fax: +972-(0)9-7740261
Mobile: +972-(0)58-888377
*** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
Don't just participate in USENET...get rewarded for it!
Natty Gur Guest
-
makthar #4
Need a few lines of code help, will pay!
You have to check for the type of the control.
Here's a snippet that help. You will have to refine it
depending on what you are trying to do.
Dim ctl As Control
Dim ctlname As String
Dim tb As TextBox
Dim tbvalue As String
For Each ctl In Page.FindControl
("form1").Controls
ctlname = ctl.ID
'At this point you can also check if name starts with txt
If Ctl.GetType.ToString=
"System.Web.UI.WebControls.TextBox" Then
tb = ctl
tb.TabIndex = 1 'or whatever
tbvalue = tb.Text
End If
Next
Ofcourse if you put this code in the page_load section
the value of the text box will be nothing.
WebControls on a form,>-----Original Message-----
>I need to figure out how to go through all of thetxtFirstName), and>find all the ones that are named with a "txt" prefix (ieIndex and put them>then retrieve the WebControl ID, Text (value), and Tabquite figure it out. I>into a collection or array.
>
>I have spent all day working on this and I just can'tpay $50 to the first>would appreciate any help you can give. I will happily>person who can come up with a solution that works!!!
>
>Thanks a bunch!
>
>Robert Johnson
>
>
>
>.
>makthar Guest



Reply With Quote

