|
 |
aspx_beginners thread: How to DIRECTLY assign a server-side variable to an attribute of a webcontrol?
Message #1 by "Douglas Chen" <dchen@m...> on Mon, 1 Oct 2001 21:06:39
|
|
How to DIRECTLY assign a server-side variable to an attribute of a
webcontrol?
I have code like this:
1: <script language="VB" runat="server">
2: Protected Sub Page_Load(Src As Object, E As EventArgs)
3: Dim ResolvedText As String = "SomeTextHere"
4: End Sub
5:</script>
6:
7:<body>
8:<DataGrid runat="Server" id="MyGrid">
9: <Columns>
10: <TemplateColumn HeaderText="<% =ResolvedText %>"
...
The problem is that in line 10, the code <% =ResolvedText %> not executed
as in an ASP page. I also tried "<%# =ResolvedText %>. That causes a
runtime error. I know I can write something like "MyGrid.Columns
(0).HeaderText = ResolvedText" in the Sub. But that is not my question.
Can anyone help?
Thank you very much in advance.
Douglas
Message #2 by "Rick Delorme" <rick@p...> on Wed, 3 Oct 2001 08:58:05 -0400
|
|
Your variable is declared local to the event handler that it is declared in.
Try to declare at the page level scope.
dim var as string
private sub .......
end sub
<body>
<DataGrid runat="Server" id="MyGrid">
<Columns>
<TemplateColumn HeaderText="<% =ResolvedText %>"
...
"Douglas Chen" <dchen@m...> wrote in message
news:106496@a..._beginners...
>
> How to DIRECTLY assign a server-side variable to an attribute of a
> webcontrol?
>
> I have code like this:
>
> 1: <script language="VB" runat="server">
> 2: Protected Sub Page_Load(Src As Object, E As EventArgs)
> 3: Dim ResolvedText As String = "SomeTextHere"
> 4: End Sub
> 5:</script>
> 6:
> 7:<body>
> 8:<DataGrid runat="Server" id="MyGrid">
> 9: <Columns>
> 10: <TemplateColumn HeaderText="<% =ResolvedText %>"
> ...
>
> The problem is that in line 10, the code <% =ResolvedText %> not executed
> as in an ASP page. I also tried "<%# =ResolvedText %>. That causes a
> runtime error. I know I can write something like "MyGrid.Columns
> (0).HeaderText = ResolvedText" in the Sub. But that is not my question.
>
> Can anyone help?
>
> Thank you very much in advance.
>
> Douglas
>
>
Message #3 by "Douglas Chen" <dchen@m...> on Wed, 3 Oct 2001 19:27:25
|
|
Thank you for your replay. The scope of variables could be a part of the
reason. Unfortunately, it still doesn't work to declare at the page level.
It seems that "<% = ResoluvedText %>" within quotation marks is treated as
a plain string instead of executable server-side code.
> Your variable is declared local to the event handler that it is declared
in.
> Try to declare at the page level scope.
>
> dim var as string
> private sub .......
> end sub
> <body>
> <DataGrid runat="Server" id="MyGrid">
> <Columns>
> <TemplateColumn HeaderText="<% =ResolvedText %>"
> ...
>
> "Douglas Chen" <dchen@m...> wrote in message
> news:106496@a..._beginners...
> >
> > How to DIRECTLY assign a server-side variable to an attribute of a
> > webcontrol?
> >
> > I have code like this:
> >
> > 1: <script language="VB" runat="server">
> > 2: Protected Sub Page_Load(Src As Object, E As EventArgs)
> > 3: Dim ResolvedText As String = "SomeTextHere"
> > 4: End Sub
> > 5:</script>
> > 6:
> > 7:<body>
> > 8:<DataGrid runat="Server" id="MyGrid">
> > 9: <Columns>
> > 10: <TemplateColumn HeaderText="<% =ResolvedText %>"
> > ...
> >
> > The problem is that in line 10, the code <% =ResolvedText %> not
executed
> > as in an ASP page. I also tried "<%# =ResolvedText %>. That causes a
> > runtime error. I know I can write something like "MyGrid.Columns
> > (0).HeaderText = ResolvedText" in the Sub. But that is not my question.
> >
> > Can anyone help?
> >
> > Thank you very much in advance.
> >
> > Douglas
> >
> >
>
>
Message #4 by "Rick Delorme" <rick@p...> on Wed, 3 Oct 2001 17:14:19 -0400
|
|
You are correct. You should include this tag in single quotes. At least that
is what you do with the databind directive when it is inside the properties
for the asp servere control tag.
Rick.
"Douglas Chen" <dchen@m...> wrote in message
news:107182@a..._beginners...
>
> Thank you for your replay. The scope of variables could be a part of the
> reason. Unfortunately, it still doesn't work to declare at the page level.
> It seems that "<% = ResoluvedText %>" within quotation marks is treated as
> a plain string instead of executable server-side code.
>
> > Your variable is declared local to the event handler that it is declared
> in.
> > Try to declare at the page level scope.
> >
> > dim var as string
> > private sub .......
> > end sub
> > <body>
> > <DataGrid runat="Server" id="MyGrid">
> > <Columns>
> > <TemplateColumn HeaderText="<% =ResolvedText %>"
> > ...
> >
> > "Douglas Chen" <dchen@m...> wrote in message
> > news:106496@a..._beginners...
> > >
> > > How to DIRECTLY assign a server-side variable to an attribute of a
> > > webcontrol?
> > >
> > > I have code like this:
> > >
> > > 1: <script language="VB" runat="server">
> > > 2: Protected Sub Page_Load(Src As Object, E As EventArgs)
> > > 3: Dim ResolvedText As String = "SomeTextHere"
> > > 4: End Sub
> > > 5:</script>
> > > 6:
> > > 7:<body>
> > > 8:<DataGrid runat="Server" id="MyGrid">
> > > 9: <Columns>
> > > 10: <TemplateColumn HeaderText="<% =ResolvedText %>"
> > > ...
> > >
> > > The problem is that in line 10, the code <% =ResolvedText %> not
> executed
> > > as in an ASP page. I also tried "<%# =ResolvedText %>. That causes a
> > > runtime error. I know I can write something like "MyGrid.Columns
> > > (0).HeaderText = ResolvedText" in the Sub. But that is not my
question.
> > >
> > > Can anyone help?
> > >
> > > Thank you very much in advance.
> > >
> > > Douglas
> > >
> > >
> >
> >
>
>
Message #5 by "Douglas Chen" <dchen@m...> on Fri, 5 Oct 2001 18:10:41
|
|
It is said that ASP.Net still supports the old syntax like <% =exp %>
along with the new one <%# =exp %>. But I cann't see it in this case.
Anyway, I can make my pages working by other means. Just wondering if MS
can implement this feature in final release.
Douglas
> You are correct. You should include this tag in single quotes. At least
that
> is what you do with the databind directive when it is inside the
properties
> for the asp servere control tag.
>
> Rick.
>
> "Douglas Chen" <dchen@m...> wrote in message
> news:107182@a..._beginners...
> >
> > Thank you for your replay. The scope of variables could be a part of
the
> > reason. Unfortunately, it still doesn't work to declare at the page
level.
> > It seems that "<% = ResoluvedText %>" within quotation marks is
treated as
> > a plain string instead of executable server-side code.
> >
> > > Your variable is declared local to the event handler that it is
declared
> > in.
> > > Try to declare at the page level scope.
> > >
> > > dim var as string
> > > private sub .......
> > > end sub
> > > <body>
> > > <DataGrid runat="Server" id="MyGrid">
> > > <Columns>
> > > <TemplateColumn HeaderText="<% =ResolvedText %>"
> > > ...
> > >
> > > "Douglas Chen" <dchen@m...> wrote in message
> > > news:106496@a..._beginners...
> > > >
> > > > How to DIRECTLY assign a server-side variable to an attribute of a
> > > > webcontrol?
> > > >
> > > > I have code like this:
> > > >
> > > > 1: <script language="VB" runat="server">
> > > > 2: Protected Sub Page_Load(Src As Object, E As EventArgs)
> > > > 3: Dim ResolvedText As String = "SomeTextHere"
> > > > 4: End Sub
> > > > 5:</script>
> > > > 6:
> > > > 7:<body>
> > > > 8:<DataGrid runat="Server" id="MyGrid">
> > > > 9: <Columns>
> > > > 10: <TemplateColumn HeaderText="<% =ResolvedText %>"
> > > > ...
> > > >
> > > > The problem is that in line 10, the code <% =ResolvedText %> not
> > executed
> > > > as in an ASP page. I also tried "<%# =ResolvedText %>. That causes
a
> > > > runtime error. I know I can write something like "MyGrid.Columns
> > > > (0).HeaderText = ResolvedText" in the Sub. But that is not my
> question.
> > > >
> > > > Can anyone help?
> > > >
> > > > Thank you very much in advance.
> > > >
> > > > Douglas
> > > >
> > > >
> > >
> > >
> >
> >
>
>
|
|
 |