RE: passing variables from .aspx.cs code pages to .aspx pages
- From: stcheng@xxxxxxxxxxxxxxxxxxxx (Steven Cheng[MSFT])
- Date: Tue, 20 Sep 2005 08:33:03 GMT
Hi RadioSignal,
Thanks for your response. Well, from your further description and the code
snippet, I've got the cause of your problem, for ASP.NET server control, we
can't assign the value in their template through
<% %> code block.
also, we can only assign top level property value for ASP.NET controls
through <%# ... %> or <%$ ...%> expressions. And for the
<XXXParameters> in the XXDataSource control, I'm afraid they can only be
delared on page statically, we can't use code expression to add them
dynamically since they're required to be fixed and determined at compiled
time much ealier before our code in <% ... %> get executed. Is there any
particular requirement in your application that you need to dynamically
define paramters for datasrouce control?
Based on my experience, we should always define the parameters statically
in the aspx page's inline template , but we can adjust those parameters'
value at runtime through DataSource control's certain events.
Thanks,
Steven Cheng
Microsoft Online Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| Thread-Topic: passing variables from .aspx.cs code pages to .aspx pages
| thread-index: AcW9K+6+QUV3lzniREapxuaXQZ8s8g==
| X-WBNR-Posting-Host: 192.85.47.2
| From: "=?Utf-8?B?UmFkaW9TaWduYWw=?=" <RadioSignal@xxxxxxxxxxxxxxxx>
| References: <B936C411-A1AB-4FEA-A207-B3B39DE46C84@xxxxxxxxxxxxx>
<XaG96bAuFHA.768@xxxxxxxxxxxxxxxxxxxxx>
<5Pn5a0ouFHA.768@xxxxxxxxxxxxxxxxxxxxx>
| Subject: RE: passing variables from .aspx.cs code pages to .aspx pages
| Date: Mon, 19 Sep 2005 08:08:03 -0700
| Lines: 166
| Message-ID: <D6D409F2-E89F-4B47-ADBC-57BA685DBFF2@xxxxxxxxxxxxx>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
| NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.framework.aspnet.webcontrols:10900
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
|
| Steven, Thank you for the help, but I am still having problems with these
| parameters. Here is my aspx.cs:
|
| public partial class Test : System.Web.UI.Page
| {
| protected string MyPatientID;
|
| protected void Page_Load(object sender, EventArgs e)
| {
| //What I'd like to do:
| MyPatientID = "13";
|
| //What I have to do:
| TextBox1.Text = "13";
| }
| }
|
| However, in aspx:
|
| <asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$
| ConnectionStrings:MyConnectionString %>"
|
| SelectCommand="SELECT PatientID, BarCode, ChartID, EmpID,
| NameID, Diagnosis, BeginTime FROM Patients WHERE (PatientID = @Param1)">
|
| <SelectParameters>
|
| What I want to do:
|
| <%Param1 = MyPatientID;%>
|
| What I have to do:
|
| <asp:ControlParameter ControlID="TextBox1" Name="Param1"
| PropertyName="Text" />
|
| </SelectParameters>
|
| </asp:SqlDataSource>
|
|
| I am receiving the error - Code block not allowed in this context.
|
| Any ideas how to get access to the MyPatientID variable in the <Select
| Parameters> section?
|
| "Steven Cheng[MSFT]" wrote:
|
| > Hi RadioSignal,
| >
| > How are you doing on this issue and does the suggestions in my last
reply
| > helps a littile? If there're anything else we can help, please feel
free to
| > post here. Thanks,
| >
| > Steven Cheng
| > Microsoft Online Support
| >
| > Get Secure! www.microsoft.com/security
| > (This posting is provided "AS IS", with no warranties, and confers no
| > rights.)
| > --------------------
| > | X-Tomcat-ID: 60741222
| > | References: <B936C411-A1AB-4FEA-A207-B3B39DE46C84@xxxxxxxxxxxxx>
| > | MIME-Version: 1.0
| > | Content-Type: text/plain
| > | Content-Transfer-Encoding: 7bit
| > | From: stcheng@xxxxxxxxxxxxxxxxxxxx (Steven Cheng[MSFT])
| > | Organization: Microsoft
| > | Date: Tue, 13 Sep 2005 02:00:47 GMT
| > | Subject: RE: passing variables from .aspx.cs code pages to .aspx pages
| > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
| > | Message-ID: <XaG96bAuFHA.768@xxxxxxxxxxxxxxxxxxxxx>
| > | Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
| > | Lines: 66
| > | Path: TK2MSFTNGXA01.phx.gbl
| > | Xref: TK2MSFTNGXA01.phx.gbl
| > microsoft.public.dotnet.framework.aspnet.webcontrols:10807
| > | NNTP-Posting-Host: tomcatimport2.phx.gbl 10.201.218.182
| > |
| > | Hi RadioSignal,
| > |
| > | Welcome to ASPNET newsgroup.
| > | Regarding on the accessing variable defined in codebehind
page(aspx.cs.)
| > | from aspx template, I think we can just make those Page member
variable
| > as
| > | non-private(protected or public). Because at runtime, the dynamically
| > | compiled page class is a concrete class derived from the codebehind
page
| > | class, so any protected or public page member variables can be
accessed
| > | from the dynamic compiled page. For example, we can define the
following
| > | page variable in codebehind:
| > |
| > | =============
| > | public partial class SimplePage : System.Web.UI.Page
| > | {
| > | protected string PageId;
| > |
| > | protected void Page_Load(object sender, EventArgs e)
| > | {
| > | PageId = "Simple Page";
| > | }
| > | ......
| > | ============
| > |
| > | then, in aspx , we can access the variable like:
| > |
| > | ....
| > | <body>
| > | <form id="form1" runat="server">
| > | <div>
| > | <%= PageId %>
| > |
| > | </div>
| > | ...
| > |
| > |
| > | Also, we can also define page's member function like this and used in
| > aspx.
| > |
| > |
| > | Thanks,
| > |
| > | Steven Cheng
| > | Microsoft Online Support
| > |
| > | Get Secure! www.microsoft.com/security
| > | (This posting is provided "AS IS", with no warranties, and confers no
| > | rights.)
| > | --------------------
| > | | Thread-Topic: passing variables from .aspx.cs code pages to .aspx
pages
| > | | thread-index: AcW30wXnzYsf2ItsR+il49U22FxHdg==
| > | | X-WBNR-Posting-Host: 192.85.47.2
| > | | From: "=?Utf-8?B?UmFkaW9TaWduYWw=?=" <RadioSignal@xxxxxxxxxxxxxxxx>
| > | | Subject: passing variables from .aspx.cs code pages to .aspx pages
| > | | Date: Mon, 12 Sep 2005 12:49:01 -0700
| > | | Lines: 5
| > | | Message-ID: <B936C411-A1AB-4FEA-A207-B3B39DE46C84@xxxxxxxxxxxxx>
| > | | MIME-Version: 1.0
| > | | Content-Type: text/plain;
| > | | charset="Utf-8"
| > | | Content-Transfer-Encoding: 7bit
| > | | X-Newsreader: Microsoft CDO for Windows 2000
| > | | Content-Class: urn:content-classes:message
| > | | Importance: normal
| > | | Priority: normal
| > | | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| > | | Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
| > | | NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| > | | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
| > | | Xref: TK2MSFTNGXA01.phx.gbl
| > | microsoft.public.dotnet.framework.aspnet.webcontrols:10804
| > | | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
| > | |
| > | | I have been using dummy invisible text boxes and labels defined in
the
| > VS
| > | | 2005 designer to pass parameters between my code behind pages and
my
| > | .aspx
| > | | pages. This works but there's got to be a better way? How do I give
my
| > | .aspx
| > | | page visibility to variables declared in my .aspx.cs code instead
of
| > | using
| > | | the dummy controls that I'm using now?
| > | |
| > |
| > |
| >
| >
|
.
- Follow-Ups:
- RE: passing variables from .aspx.cs code pages to .aspx pages
- From: RadioSignal
- RE: passing variables from .aspx.cs code pages to .aspx pages
- References:
- passing variables from .aspx.cs code pages to .aspx pages
- From: RadioSignal
- RE: passing variables from .aspx.cs code pages to .aspx pages
- From: Steven Cheng[MSFT]
- RE: passing variables from .aspx.cs code pages to .aspx pages
- From: Steven Cheng[MSFT]
- RE: passing variables from .aspx.cs code pages to .aspx pages
- From: RadioSignal
- passing variables from .aspx.cs code pages to .aspx pages
- Prev by Date: RE: Tabstrip link style***
- Next by Date: Re: Problem Printing using IWebBrowser2 from IWAM Account on Server 2003
- Previous by thread: RE: passing variables from .aspx.cs code pages to .aspx pages
- Next by thread: RE: passing variables from .aspx.cs code pages to .aspx pages
- Index(es):