473,839 Members | 1,330 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Trying to find ClientID of web form - Update

This works:

<form>
<asp:TextBox id="name" />
<%= name.ClientID %>
</form>

But this DOES NOT work:

<form>
<datagrid id="dg">
<asp:TextBox id="name" />
<%= name.ClientID %>
</datagrid>
</form>

and throws an error of:
Compilation Error
Compiler Error Message: BC30451: Name 'name' is not declared.

Any ida why???

TIA
....Geshel
--
*************** *************** *************** *************** **********
My reply-to is an automatically monitored spam honeypot. Do not use it
unless you want to be blacklisted by SpamCop. Please reply to my first
name at my last name dot org.
*************** *************** *************** *************** **********
Nov 21 '05 #1
19 1615
This works fine :

<form runat="server">
<datagrid id="dg">
<asp:TextBox id="name" Runat="Server" />
<%=name.ClientI D %>
</datagrid>
</form>

Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Espańol
Ven, y hablemos de ASP.NET...
=============== =======

"Neo Geshel" <go****@geshel. org> wrote in message
news:O4******** ******@tk2msftn gp13.phx.gbl...
This works:

<form>
<asp:TextBox id="name" />
<%= name.ClientID %>
</form>

But this DOES NOT work:

<form>
<datagrid id="dg">
<asp:TextBox id="name" />
<%= name.ClientID %>
</datagrid>
</form>

and throws an error of:
Compilation Error
Compiler Error Message: BC30451: Name 'name' is not declared.

Any ida why???

TIA
...Geshel
--
*************** *************** *************** *************** **********
My reply-to is an automatically monitored spam honeypot. Do not use it
unless you want to be blacklisted by SpamCop. Please reply to my first
name at my last name dot org.
*************** *************** *************** *************** **********

Nov 21 '05 #2
I just realized you are trying to use an asp.net datagrid control,
but are using html <datagrid...> syntax.

You can't insert a textbox inside a datagrid unless
you declare it in code as an ItemTemplate.

That's why you're getting the "Name 'name' is not declared." error.

Try this, if it suits you.

<form runat="server">
<asp:datagrid id="dg" runat="server">
</asp:DataGrid>
<asp:TextBox id="name" runat="Server" />
<br/>
<%=name.ClientI D %>
</form>

If you want a textbox inserted inside a datagrid,
you'd do well to study Scott Mitchell's excellent datagrid tutorial :
http://aspnet.4guysfromrolla.com/articles/040502-1.aspx

The 9th part of the tutorial explains how to do what you want to do:
http://aspnet.4guysfromrolla.com/articles/090902-1.aspx


Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Espańol
Ven, y hablemos de ASP.NET...
=============== =======

"Juan T. Llibre" <no***********@ nowhere.com> wrote in message
news:Ox******** ******@TK2MSFTN GP15.phx.gbl...
This works fine :

<form runat="server">
<datagrid id="dg">
<asp:TextBox id="name" Runat="Server" />
<%=name.ClientI D %>
</datagrid>
</form>

Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Espańol
Ven, y hablemos de ASP.NET...
=============== =======

"Neo Geshel" <go****@geshel. org> wrote in message
news:O4******** ******@tk2msftn gp13.phx.gbl...
This works:

<form>
<asp:TextBox id="name" />
<%= name.ClientID %>
</form>

But this DOES NOT work:

<form>
<datagrid id="dg">
<asp:TextBox id="name" />
<%= name.ClientID %>
</datagrid>
</form>

and throws an error of:
Compilation Error
Compiler Error Message: BC30451: Name 'name' is not declared.

Any ida why???

TIA
...Geshel
--
*************** *************** *************** *************** **********
My reply-to is an automatically monitored spam honeypot. Do not use it
unless you want to be blacklisted by SpamCop. Please reply to my first
name at my last name dot org.
*************** *************** *************** *************** **********


Nov 21 '05 #3
Juan T. Llibre wrote:
This works fine :

<form runat="server">
<datagrid id="dg">
<asp:TextBox id="name" Runat="Server" />
<%=name.ClientI D %>
</datagrid>
</form>



Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Espa�ol
Ven, y hablemos de ASP.NET...
=============== =======

Unfortunately, not for me. It throws that error, and I don't know why.
Any clues?

...Geshel
--
*************** *************** *************** *************** **********
My reply-to is an automatically monitored spam honeypot. Do not use it
unless you want to be blacklisted by SpamCop. Please reply to my first
name at my last name dot org.
*************** *************** *************** *************** **********
Nov 21 '05 #4
Juan T. Llibre wrote:
I just realized you are trying to use an asp.net datagrid control,
but are using html <datagrid...> syntax.

You can't insert a textbox inside a datagrid unless
you declare it in code as an ItemTemplate.

That's why you're getting the "Name 'name' is not declared." error.

Try this, if it suits you.

<form runat="server">
<asp:datagrid id="dg" runat="server">
</asp:DataGrid>
<asp:TextBox id="name" runat="Server" />
<br/>
<%=name.ClientI D %>
</form>

If you want a textbox inserted inside a datagrid,
you'd do well to study Scott Mitchell's excellent datagrid tutorial :
http://aspnet.4guysfromrolla.com/articles/040502-1.aspx

The 9th part of the tutorial explains how to do what you want to do:
http://aspnet.4guysfromrolla.com/articles/090902-1.aspx


*sigh*

Here I was hoping to save having to post nearly 300 lines of code by
providing a simplified illustration. Really, I didn't fall off the
turnip truck yesterday. I actually have a decent idea of what I should
be doing. I'm just missing a few pieces of the puzzle.

But since you've already thrown down the gauntlet, I hope you don't mind
putting your big mouth where your (probably even bigger) ego is and
going through my code to see what might be up.

Well, here goes:

<!-- begin code -->

<%@ Page Language="VB" Debug="true" %>
<% @Import Namespace="Syst em.Data" %>
<% @Import Namespace="Syst em.Data.OleDb" %>
<% @Import Namespace="Syst em.Configuratio n" %>
<% @Import Namespace="Syst em.Web.UI" %>
<% @Import Namespace="Syst em.Web.UI.WebCo ntrols" %>
<% @Import Namespace="Syst em.Web.UI.HtmlC ontrols" %>
<% @Import Namespace="Syst em.IO" %>
<% @Import Namespace="Syst em.Drawing" %>
<% @Import Namespace="Syst em.Drawing.Imag ing" %>
<%@ OutputCache Duration="20" VaryByParam="*" Location="None"
VaryByHeader="U ser-Agent"%>
<%@ Register TagPrefix="METZ " TagName="Meta" Src="/ssi/meta.ascx" %>
<%@ Register TagPrefix="METZ " TagName="Head" Src="/ssi/head.ascx" %>
<%@ Register TagPrefix="METZ " TagName="Foot" Src="/ssi/foot.ascx" %>
<METZ:Meta Id="ctlMeta" Runat="Server" />
<METZ:Head Id="ctlHead" Runat="Server" />
<script runat="server">
Sub Page_Load(sende r as Object, e as EventArgs)
If Not Page.IsPostBack Then
BindData()
End If
End Sub
Sub BindData()
Dim myConn as New
OleDbConnection (ConfigurationS ettings.AppSett ings("strConn") )
Dim myCmd as New OleDbCommand("S ELECT * FROM tblNews", myConn)
myConn.Open()
dg.DataSource = myCmd.ExecuteRe ader(CommandBeh avior.CloseConn ection)
dg.DataBind()
myConn.Close()
End Sub
Sub dg_Edit(sender As Object, e As DataGridCommand EventArgs)
dg.ShowFooter = False
dg.EditItemInde x = e.Item.ItemInde x
BindData()
End Sub
Sub dg_Update(sende r As Object, e As DataGridCommand EventArgs)
Dim imgContent as Object = e.Item.Cells(3) .Controls(1)
Dim imgStream As Stream = imgContent.Post edFile.InputStr eam()
Dim imgLen As Integer = imgContent.Post edFile.ContentL ength
Dim imgType as String = imgContent.Post edFile.ContentT ype
If Not imgStream Is Nothing And imgLen > 0 And (imgType =
"image/jpeg" Or imgType = "image/pjpeg") Then 'If new image was selected
for upload, then author intends to replace original image with new one
Dim imgBin() as Byte
imgBin = createThumbnail (imgStream, 200, 200)
Dim myConn as New
OleDbConnection (ConfigurationS ettings.AppSett ings("strConn") )
Dim myCmd as New OleDbCommand("U PDATE tblNews SET [Date]=@Date,
[Title]=@Title, [Image]=@Image, [Comment]=@Comment WHERE [ID]=@ID", myConn)
myConn.Open()
myCmd.CommandTy pe = CommandType.Tex t
myCmd.Parameter s.Add("@Date", OleDbType.Date) .Value =
String.Format(" {0:dddd, dd MMMMM, yyyy}",
Convert.ToDateT ime(e.Item.Cell s(1).Controls(0 )))'CType(e.Ite m.Cells(1).Cont rols(0),
Textbox).Text
myCmd.Parameter s.Add("@Title", OleDbType.VarWC har).Value =
CType(e.Item.Ce lls(2).Controls (1), Textbox).Text.R eplace("'","’ ")
myCmd.Parameter s.Add("@Image", OleDbType.LongV arBinary).Value = imgBin
myCmd.Parameter s.Add("@Comment ", OleDbType.LongV arWChar).Value =
CType(e.Item.Ce lls(4).Controls (1), Textbox).Text.R eplace("'","’ ")
myCmd.Parameter s.Add("@ID", OleDbType.Integ er).Value =
e.Item.Cells(0) .Text
myCmd.ExecuteNo nQuery()
myConn.Close()
dg.ShowFooter = True
dg.EditItemInde x = -1
BindData()
Else 'If no new image was selected for upload, then author only
intends to update the name and/or comments
Dim myConn as New
OleDbConnection (ConfigurationS ettings.AppSett ings("strConn") )
Dim myCmd as New OleDbCommand("U PDATE tblNews SET [Date]=@Date,
[Title]=@Title, [Comment]=@Comment WHERE [ID]=@ID", myConn)
myConn.Open()
myCmd.CommandTy pe = CommandType.Tex t
Dim strDate as String = CType(e.Item.Ce lls(1).Controls (0),
Textbox).Text
strDate = "#" & strDate & "#"
myCmd.Parameter s.Add("@Date", OleDbType.Date) .Value = "#" & strDate
& "#"'CType(e.Ite m.Cells(1).Cont rols(0), Textbox).Text
myCmd.Parameter s.Add("@Title", OleDbType.VarWC har).Value =
CType(e.Item.Ce lls(2).Controls (1), Textbox).Text.R eplace("'","’ ")
myCmd.Parameter s.Add("@Comment ", OleDbType.LongV arWChar).Value =
CType(e.Item.Ce lls(4).Controls (1), Textbox).Text.R eplace("'","’ ")
myCmd.Parameter s.Add("@ID", OleDbType.Integ er).Value =
e.Item.Cells(0) .Text
myCmd.ExecuteNo nQuery()
myConn.Close()
dg.ShowFooter = True
dg.EditItemInde x = -1
BindData()
End If
End Sub
Sub dg_Cancel(sende r As Object, e As DataGridCommand EventArgs)
dg.ShowFooter = True
dg.EditItemInde x = -1
BindData()
End Sub
Sub dg_Delete(sende r As Object, e As DataGridCommand EventArgs)
If e.CommandName = "Delete" Then
Dim myConn as New
OleDbConnection (ConfigurationS ettings.AppSett ings("strConn") )
Dim myCmd as New OleDbCommand("D ELETE * From tblNews WHERE [ID] =
@ID", myConn)
myConn.Open()
myCmd.CommandTy pe = CommandType.Tex t
myCmd.Parameter s.Add("@ID", OleDbType.Integ er).Value =
dg.DataKeys(e.I tem.ItemIndex)
myCmd.ExecuteNo nQuery()
myConn.Close()
dg.ShowFooter = True
dg.EditItemInde x = -1
BindData()
End If
End Sub
Sub dg_Insert(sende r As Object, e As DataGridCommand EventArgs)
If e.CommandName = "Insert" Then
Dim imgContent as Object = e.Item.Cells(3) .Controls(1)
Dim imgStream As Stream = imgContent.Post edFile.InputStr eam()
Dim imgLen As Integer = imgContent.Post edFile.ContentL ength
Dim imgType as String = imgContent.Post edFile.ContentT ype
If Not imgStream Is Nothing And imgLen > 0 And (imgType =
"image/jpeg" Or imgType = "image/pjpeg") Then
Dim imgBin() as Byte
imgBin = createThumbnail (imgStream, 200, 200)
Dim myConn as New
OleDbConnection (ConfigurationS ettings.AppSett ings("strConn") )
Dim myCmd as New OleDbCommand("I NSERT INTO tblNews ([Date],
[Title], [Image], [Comment]) VALUES (@Date, @Title, @Image, @Comment)",
myConn)
myConn.Open()
myCmd.CommandTy pe = CommandType.Tex t
myCmd.Parameter s.Add("@Date", OleDbType.Date) .Value =
CType(e.Item.Ce lls(1).Controls (0), Textbox).Text
myCmd.Parameter s.Add("@Title", OleDbType.VarWC har).Value =
CType(e.Item.Ce lls(2).Controls (1), Textbox).Text.R eplace("'","’ ")
myCmd.Parameter s.Add("@Image", OleDbType.LongV arBinary).Value =
imgBin
myCmd.Parameter s.Add("@Comment ", OleDbType.LongV arWChar).Value =
CType(e.Item.Ce lls(4).Controls (1), Textbox).Text.R eplace("'","’ ")
myCmd.ExecuteNo nQuery()
myConn.Close()
dg.EditItemInde x = -1
BindData()
Else
Dim myConn as New
OleDbConnection (ConfigurationS ettings.AppSett ings("strConn") )
Dim myCmd as New OleDbCommand("I NSERT INTO tblNews ([Date],
[Title], [Comment]) VALUES (@Date, @Title, @Comment)", myConn)
myConn.Open()
myCmd.CommandTy pe = CommandType.Tex t
myCmd.Parameter s.Add("@Date", OleDbType.Date) .Value =
CType(e.Item.Ce lls(1).Controls (0), Textbox).Text
myCmd.Parameter s.Add("@Title", OleDbType.VarWC har).Value =
CType(e.Item.Ce lls(2).Controls (1), Textbox).Text.R eplace("'","’ ")
myCmd.Parameter s.Add("@Comment ", OleDbType.LongV arWChar).Value =
CType(e.Item.Ce lls(4).Controls (1), Textbox).Text.R eplace("'","’ ")
myCmd.ExecuteNo nQuery()
myConn.Close()
dg.EditItemInde x = -1
BindData()
End If
End If
End Sub
Private Function createThumbnail (ByVal ImageStream As Stream, ByVal
tWidth As Double, ByVal tHeight As Double) As Byte()
Dim g As System.Drawing. Image
=System.Drawing .Image.FromStre am(ImageStream)
Dim thumbSize As New Size()
thumbSize =NewthumbSize(g .Width, g.Height, tWidth, tHeight)
Dim imgOutput As New Bitmap(g, thumbSize.Width , thumbSize.Heigh t)
Dim imgStream As New MemoryStream()
Dim thisFormat = g.RawFormat
imgOutput.Save( imgStream, thisFormat)
Dim imgbin(imgStrea m.Length) As Byte
imgStream.Posit ion = 0
Dim intStatus as Integer = imgStream.Read( imgbin, 0, imgbin.Length)
g.Dispose()
imgOutput.Dispo se()
Return imgbin
End Function
Function NewthumbSize(By Val currentwidth As Double, ByVal currentheight
As Double, ByVal newWidth As Double, ByVal newHeight As Double)
Dim tempMultiplier As Double
If currentheight > currentwidth Then ' portrait
tempMultiplier = newHeight / currentheight
Else
tempMultiplier = newWidth / currentwidth
End If
Dim NewSize As New Size(CInt(curre ntwidth * tempMultiplier) ,
CInt(currenthei ght * tempMultiplier) )
Return NewSize
End Function
Function FormatData(sIte m) as String
FormatData=sIte m.Replace(vbcrl f,"<br />")
End Function
</script>
<div id="content">
<div class="floatrig ht">
<div id="timer"></div>
You are here: <a href="/default.aspx">H ome</a> » News &amp; Info »
<b>News</b>
</div>
<h2>News - News Edit</h2>
<p>Here is where you add the latest news title, as well as an “eyecatch
photo” (something appropriately gorgeous) and a short description(a
paragraph or two) about the news.</p>
<p>Please Remember:</p>
<ul class="alert">
<li>If you are to <strong><em>EVE R</em></strong> delete a News entry,
please understand that everything in that entry, including photos and
their associated comments, will also be deleted. Irreversably. You have
been warned.</li>
<li>All fields except the Image field must be filled, otherwise you
will get a very abrupt and nasty error message from the server itself.
As a computer, it gets very cranky when it’s given stuff it can’t work
with. You have been warned.</li>
</ul>
<form id="Form1" method="post" runat="server"
enctype="multip art/form-data">
<asp:datagrid id="dg" runat="server"
showheader="tru e"
showfooter="tru e"
autogeneratecol umns="False"
edititemstyle-backcolor="#ffc ccc"
oneditcommand=" dg_Edit"
onupdatecommand ="dg_Update"
oncancelcommand ="dg_Cancel"
ondeletecommand ="dg_Delete"
onitemcommand=" dg_Insert"
datakeyfield="I D"
cellpadding="10 "
width="758">
<HeaderStyle backcolor="#000 000" forecolor="#fff fff" font-bold="true"
horizontalalign ="center" />
<ItemStyle backcolor="#fff fff" forecolor="#000 000" />
<AlternatingIte mStyle backcolor="#ccc ccc" />
<Columns>
<asp:BoundColum n DataField="ID" HeaderText="ID" ReadOnly="true"
Visible="false" />
<asp:TemplateCo lumn HeaderText="Dat e">
<FooterTemplate >
<asp:TextBox ID="add_Date" Text='<%# DateTime.Now.To String("dddd, dd
MMMM, yyyy") %>' Runat="Server" style="display: none;" />
<img src="/images/cal.png" alt="Choose Calendar Date"
id="calendar_tr igger" /> <span id="show_date"> <%=
DateTime.Now.To String("dddd, dd MMMM, yyyy") %></span>
<script type="text/javascript">
Calendar.setup( {
inputField : "", // id of the input field
displayArea : "show_date" , // ID of the span where
the date is to be shown
button : "calendar_trigg er", // trigger button
(well, IMG in our case)
align : "br", // alignment (defaults to "Bl")
singleClick : true
});
</script>

<!-- this actually fails with the error message -->
<%= add_Date.Client ID %>

</FooterTemplate>
<ItemTemplate >
<%# String.Format(" {0:dddd, dd MMMMM, yyyy}",
Convert.ToDateT ime(Container.D ataItem("Date") )) %>
</ItemTemplate>
<EditItemTempla te>
<asp:TextBox ID="edit_Date" Text='<%# String.Format(" {0:dddd, dd MMMMM,
yyyy}", Convert.ToDateT ime(Container.D ataItem("Date") )) %>'
Runat="Server" style="display: none;" />
<img src="/images/cal.png" alt="Choose Calendar Date"
id="calendar_tr igger" /> <span id="show_date"> <%#
String.Format(" {0:dddd, dd MMMMM, yyyy}",
Convert.ToDateT ime(Container.D ataItem("Date") )) %></span>
<script type="text/javascript">
Calendar.setup( {
inputField : "", // id of the input field
displayArea : "show_date" , // ID of the span where
the date is to be shown
button : "calendar_trigg er", // trigger button
(well, IMG in our case)
align : "br", // alignment (defaults to "Bl")
singleClick : true
});
</script>

<!-- this actually fails with the error message -->
<%= edit_Date.Clien tID %>

</EditItemTemplat e>
</asp:TemplateCol umn>
<asp:TemplateCo lumn HeaderText="Nam e">
<FooterTemplate >
<asp:TextBox ID="add_Title" MaxLength="50" Runat="Server" />
</FooterTemplate>
<ItemTemplate >
<%# Container.DataI tem("Title") %>
</ItemTemplate>
<EditItemTempla te>
<asp:TextBox ID="edit_Title " MaxLength="50" Text='<%#
Container.DataI tem("Title") %>' Runat="server" />
</EditItemTemplat e>
</asp:TemplateCol umn>
<asp:TemplateCo lumn HeaderText="Ima ge">
<FooterTemplate >
<input type="file" id="add_Image" Runat="server" />
</FooterTemplate>
<ItemTemplate >
<img src="/displayimage.as px?table=tblNew s&id=<%#
Container.DataI tem("ID") %>" alt="Thumbnail" />
</ItemTemplate>
<EditItemTempla te>
<input type="file" id="edit_Image " Runat="server" />
</EditItemTemplat e>
</asp:TemplateCol umn>
<asp:TemplateCo lumn HeaderText="Com ment">
<FooterTemplate >
<asp:TextBox ID="add_Comment " Columns="30" Rows="4"
TextMode="Multi Line" Wrap="True" Runat="Server" />
</FooterTemplate>
<ItemTemplate >
<%# FormatData(Cont ainer.DataItem( "Comment")) %>
</ItemTemplate>
<EditItemTempla te>
<asp:TextBox ID="edit_Commen t" Columns="30" Rows="4"
TextMode="Multi Line" Wrap="True" Text='<%# Container.DataI tem("Comment")
%>' Runat="server" />
</EditItemTemplat e>
</asp:TemplateCol umn>
<asp:EditComman dColumn HeaderText="Edi t" EditText="Edit"
ButtonType="Pus hButton" UpdateText="Upd ate" CancelText="Can cel" />
<asp:TemplateCo lumn HeaderText="Del ete">
<FooterTemplate >
<asp:Button CommandName="In sert" Text="Add" ID="btnAdd"
Runat="server" />
</FooterTemplate>
<ItemTemplate >
<asp:Button CommandName="De lete" Text="Delete" ID="btnDel"
Runat="server" />
</ItemTemplate>
<ItemStyle HorizontalAlign ="center" />
<FooterStyle HorizontalAlign ="center" />
</asp:TemplateCol umn>
</Columns>
</asp:datagrid><% = add_Date.Client ID %>
</form>
</div>
<METZ:Foot Id="ctlFoot" Runat="Server" />

<!-- End Code -->

Have fun.

...Geshel
--
*************** *************** *************** *************** **********
My reply-to is an automatically monitored spam honeypot. Do not use it
unless you want to be blacklisted by SpamCop. Please reply to my first
name at my last name dot org.
*************** *************** *************** *************** **********
Nov 21 '05 #5
re:
I hope you don't mind putting your big mouth where your (probably even bigger) ego is


Maybe when you acquire some manners.

That, sir, was uncalled for.


Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Espańol
Ven, y hablemos de ASP.NET...
=============== =======

"Neo Geshel" <go****@geshel. org> wrote in message
news:eK******** ********@TK2MSF TNGP09.phx.gbl. ..

But since you've already thrown down the gauntlet, I hope you don't mind
putting your big mouth where your (probably even bigger) ego is and
going through my code to see what might be up.

Nov 21 '05 #6
Neo,

In these newsgroups is almost everybody helping for free (Including Juan).
You can take an answer as it is. I have earlier seen that the way you thread
answers in not inviting to give you answers. Probably am I not the only one
who has seen this.

I saw no parts in the help from Juan were I could add something, therefore I
don't understand your behaviour.

This message is meant to help you.

Cor
Nov 21 '05 #7
Juan T. Llibre wrote:
re:
I hope you don't mind putting your big mouth where your (probably even bigger) ego is

Maybe when you acquire some manners.

That, sir, was uncalled for.


Yes, but so was your condescending tone, and your act of treating me
like someone who didn't even know the basics. If I was really doing my
DataGrids like that, do you think that finding the ClientID would really
be at the top of my priority list? I don't think so.

The first rule in creating any piece of code is to start with the
basics, and add things as you go along. As the saying goes, "you cannot
climb a mountain in a single step". I started out with a basic DataGrid,
and then added features (add, edit, delete, etc.) as I went along,
testing all the while to ensure I wasn't making major mistakes. Now I
have advanced to the point where I need to be able to provide the ID of
a form element to a piece of client-side JavaScript (for a pop-up DHTML
calendar). Since ASP.NET changes the ID that a form element is given to
something of its own choosing, I needed to pass this client-side ID on
to the JavaScript so it could fill the form field with the results.

My problem came when I tried to call this client-side ID. While this
works quite well:

<%= dg.ClientID %>

because "dg" is the ID of the DataGrid; I get a return of "dg", which is
the client-side ID of the Table that the DataGrid creates. However, when
I do this:

<%= formelement.Cli entID %>

where "formelemen t" is the ID that I give an <asp:textbox />, I get the
error message no matter what I do. I cannot retrieve the client-side ID
of a form element once it is within a DataGrid, and I am stumped.

Since I have run into that problem, I have looked at over 500+ web pages
trying to discover why calling the client ID of a form element that is
within a DataGrid does not work for me. Simply put, I have tried my best
to do my homework ahead of time. To this date, I have not found an
answer. I tried to get an answer from this group by posting a stylized
chunk of code that *might* have saved me from having to post ~300 lines
of code, but instead I get a very condescending answer from you that
makes me feel like I'm a total idiot for having even THOUGHT about
posting to this ng (your reply, translated: "Go back to nursery school,
you can't even read yet!").

Since you treated me like I had just fallen off the turnip truck, like
some wet-behind-the-ears brat that needed to be treated with kid gloves
and spoon-fed the basics, I simply decided to hold up a mirror to show
you how it felt. Not a nice feeling, is it?

Next time, try not to assume the worst, ok? I tend to be like Clark Kent
- without the impressive alter ego - (insults don't affect me much), but
when you automatically assumed that I didn't even know the basics
(without even bothering to check my actual skill level or ask for my
source), I became just a wee bit pissed off. If I wasn't even getting my
DataGrid correct, I highly doubt that finding the ClientID of a form
element would even be on my radar. Hell, the asp.net parser would have
thrown errors for the DataGrid long before it would have complained
about my attempts to find the ClientID of a form element. As an MVP, you
should have known this.

Cheers.
....Geshel
--
*************** *************** *************** *************** **********
My reply-to is an automatically monitored spam honeypot. Do not use it
unless you want to be blacklisted by SpamCop. Please reply to my first
name at my last name dot org.
*************** *************** *************** *************** **********
Nov 21 '05 #8
Cor Ligthert wrote:
Neo,

In these newsgroups is almost everybody helping for free (Including Juan).
You can take an answer as it is. I have earlier seen that the way you thread
answers in not inviting to give you answers. Probably am I not the onlyone
who has seen this.

I saw no parts in the help from Juan were I could add something, therefore I
don't understand your behaviour.

This message is meant to help you.

Cor


It wasn't so much *what* he said, Cor. It was *how* he said it.

He:
• Automatically assumed that I knew NOTHING, based on an intentionally
short snippet (~6 lines) of code
• Didn't even ask for my full source, to see if his assumption was
correct or not
• Pointed me toward docs that I would have *had* to master long before I
got to this stage ("you're an idiot, go back to the basics!")

Yes, there are a lot of newbies in these ng's, but I am asking a very
specific question that requires being able to do a whole bunch of things
correctly first (including correctly creating a DataGrid). If I wasn't
doing my DataGrid's correctly, the ASP.NET parser would complain about
*that* long before it complained about my attempts to retrieve the
ClientID of a form element.

Perhaps I got a little rough with him, but he could have handled things
a lot differently as well. I'm not an idiot, and I've tried my best to
do my homework (15+ Google searches and 500+ web pages) before I turned
to these ng's. I might not be an MVP, but that's no reason to treat me
like a simpleton.

...Geshel
--
*************** *************** *************** *************** **********
My reply-to is an automatically monitored spam honeypot. Do not use it
unless you want to be blacklisted by SpamCop. Please reply to my first
name at my last name dot org.
*************** *************** *************** *************** **********
Nov 21 '05 #9
re:
Perhaps I got a little rough with him
You sure did, and undeservedly, I'll add.

re:I'm not an idiot
You sure acted like one.

re:I might not be an MVP


Please keep that out of this discussion.

You already started this thread by claiming that you had
checked "25+ MVP sites" when -actually- *none* of the
sites you linked to are MVP sites.

So, this is the *second* time in this thread that you are unfair to MVPs.

You have some sort of "MVPness envy" and lashed out angrily
at me imagining an attitude that only exists in your mind as a
way to compensate for your having a hard time with some code.

We all have problems.
Most of us don't blame others, and particularly not MVPs, for them.


Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Espańol
Ven, y hablemos de ASP.NET...
=============== =======

"Neo Geshel" <go****@geshel. org> wrote in message
news:uK******** *******@TK2MSFT NGP12.phx.gbl.. .

Perhaps I got a little rough with him
I'm not an idiot
I might not be an MVP
....Geshel
Nov 21 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2400
by: Neo Geshel | last post by:
I need to get the ClientID of a form field for some JavaScript. About 25+ web sites I visited recommend the following method for finding the client ID of a web form: Web Form -> <asp:TextBox ID="datefield" type="hidden" Runat="Server" /> Client ID -> <%= datefield.ClientID() %> Unfortunately, this only provides the following error: Compilation Error
25
4080
by: Neo Geshel | last post by:
This works: <form> <asp:TextBox id="name" /> <%= name.ClientID %> </form> But this DOES NOT work: <form>
2
1516
by: Neo Geshel | last post by:
After pouring over about a dozen sites that clearly dealt with ClientID all by itself, I came to the realization that about 2/3+ of them were doing it wrong. It is indeed impossible to grab the Client ID of a form field from within a DataGrid like this: <%= FormFieldID.ClientID %>. At least, not without extra work. How did I do this? I created a new DataGrid from scratch, with a form above it and a form inside of it. This was a page...
0
9697
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10908
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10649
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9426
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7829
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7018
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5682
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5867
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4487
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.