Go Back   Velocity Reviews > Newsgroups > ASP Net
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

ASP Net - Response.Write help

 
Thread Tools Search this Thread
Old 11-04-2009, 07:52 AM   #1
Default Response.Write help


Hello
I want to know that can I use Response.Write for ouput value of a property
for instance <Td width='<%= StaticFunction() %>' />

thanks in advance




pers
  Reply With Quote
Old 11-04-2009, 07:59 AM   #2
Alexey Smirnov
 
Posts: n/a
Default Re: Response.Write help
On Nov 4, 8:52*am, "pers" <reza...@hotmail.com> wrote:
> Hello
> I want to know that can I use Response.Write for ouput value of a property
> for instance <Td *width='<%= *StaticFunction() %>' />
>
> thanks in advance


protected string StaticFunction()
{
return "50";
}


Alexey Smirnov
  Reply With Quote
Old 11-04-2009, 02:31 PM   #3
David
 
Posts: n/a
Default Re: Response.Write help
I read that as...

Response.Write("<Td width='<%= StaticFunction() %>' />")

though I could be wrong...

If that is the case, then add to what Alexy wrote...

Response.Write("<Td width='" + StaticFunction() + "' />")


--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available


"Alexey Smirnov" <> wrote in message
news:eebc6591-4ee3-4404-9b30-...
On Nov 4, 8:52 am, "pers" <reza...@hotmail.com> wrote:
> Hello
> I want to know that can I use Response.Write for ouput value of a property
> for instance <Td width='<%= StaticFunction() %>' />
>
> thanks in advance


protected string StaticFunction()
{
return "50";
}




David
  Reply With Quote
Old 11-04-2009, 04:31 PM   #4
David
 
Posts: n/a
Default Re: Response.Write help
Lets not start the top post / bottom post debate. I post where my cursor is
placed when I respond. If the rules change, tell MS.

I know how the = works, I read his question as how to write out the whole
string of <Td width='<%= StaticFunction() %>' /> in a Response.Write
statement, which of course won't really work... the <%=....%> would require
some form of very late binding to evaluate the StaticFunction, which won't
work, hence my alternative of writing out without the <%= %>.

The question was about writing it out, not really about the rights and
wrongs of writing it in a Response.Write. If I was to be writing something
out using Response.Write, I would do it that way, alternatively, I would be
using a label or a literal to write it...

<asp:Literal id="MyLit" runat="server" Text="<%=StaticFunction()%>" />

--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available


"Mark Rae [MVP]" <> wrote in message
news:...
> "David" <> wrote in message
> news:...
>
> [please don't top-post]
>
>>> I want to know that can I use Response.Write for ouput value of a
>>> property
>>> for instance <Td width='<%= StaticFunction() %>' />
>>>
>>> thanks in advance

>>
>> protected string StaticFunction()
>> {
>> return "50";
>> }

>
>> I read that as...
>>
>> Response.Write("<td width='<%= StaticFunction() %>' />")
>>
>> though I could be wrong...

>
> You are. The equals sign is shorthand for Response.Write and is used to
> inject server-side content into client-side markup - that's what <%...%>
> is for.
>
>
>> If that is the case, then add to what Alexy wrote...
>>
>> Response.Write("<td width='" + StaticFunction() + "' />")

>
> That is server-side code which is trying to inject additional characters
> into the HTML stream, and should be avoided at all costs. ASP.NET is
> object-orentated, not liner like ASP, and you often have very little
> control over where the characters you are injecting will actually end up.
> However, this problem doesn't exist in the way Alexey demonstrated because
> the injected characters can only appear between the <%...%> tags.
>
>
> --
> Mark Rae
> ASP.NET MVP
> http://www.markrae.net





David
  Reply With Quote
Old 11-05-2009, 08:13 AM   #5
Göran Andersson
 
Posts: n/a
Default Re: Response.Write help
pers wrote:
> Hello
> I want to know that can I use Response.Write for ouput value of a property
> for instance <Td width='<%= StaticFunction() %>' />
>
> thanks in advance
>


Yes.

The method that you want to call has to be protected (or public) so that
the page can reach it.

--
Göran Andersson
_____
http://www.guffa.com


Göran Andersson
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
response write Homeworker Computer Support 3 04-23-2007 09:58 AM
Unable to Read/Set Text Box in ASPX Web page using Javascript rameshk75 Software 0 10-25-2006 03:34 PM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46