Trick or Treat? About Server Control

F

farmer

<%@ Page Language="C#" Debug="true"%>
<SCRIPT language="C#" runat="server">
void Alt(Object From,EventArgs aEventArgs){
Info.Text=((LinkButton)From).Text;
}
</script>
<HTML>
<BODY>
<form runat="server">
<%
Menu.Text="Home";
%>
<asp:LinkButton Id=Menu OnClick=Alt RunAt=Server/>
<br>
Text:<asp:Label Id=Info runat=Server />
</form>
</BODY></HTML>

------------------------------------
If:
Menu.Text="Home"
is work,why Alt() can't get the control's property(Menu.Text has
nothing)?
if not,we indeed see the text on UI.
I miss what here?
 
G

Grant Merwitz

what are you trying to retrieve with the line:
Info.Text=((LinkButton)From).Text;
There is nothing with the Id From?

try change that line to read
info.Text = Menu.Text;
 
F

farmer

Grant said:
what are you trying to retrieve with the line:
Info.Text=((LinkButton)From).Text;
There is nothing with the Id From?

try change that line to read
info.Text = Menu.Text;

Id From is not a Control'Id directly,it is current Event Object,also
saying:"Sender","Src",or any variable name we name it like the method
defines:

void Alt(Object From,EventArgs aEventArgs){
...
...
 
G

Grant Merwitz

Sorry about that.,
So used to writing "Object Sender" i never even picked that up

Strange how its not working though. Sorry, no more suggestions
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top