Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 5th, 2005, 11:34 AM
Registered User
 
Join Date: Mar 2005
Posts: 9
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to Anup Gavate Send a message via Yahoo to Anup Gavate
Default can any one help me

I am a new .NET developer and before worked on ASP.

I need to know if i can use code given below successfully in ASP :)
Actually i am using this code for paging and i need to apply same code in ASP.net for paging.

        'Display Paging
        Response.Write("<tr><td colspan='2'>")
        Response.Write("<form name='paging' method='post' action='gift_experiences.aspx'>")
        Response.Write("<table width='100%' border='0' cellspacing='0' cellpadding='0' align='center'><tr>")
        Response.Write("<td height='20' valign='middle'>")
        If intPageNumber = 1 Then
            Response.Write("<< Previous")
        Else
            Response.Write("<a href='gift_experiences.aspx?CatId=" & intCatId & "&Page=" & (intPageNumber - 1) & "'><< Previous</a>")
        End If
        Response.Write("<img src='/images/spacer.gif' width='10' height='1'>")
        If intPageNumber = intTotalPages Then
            Response.Write("Next >>")
        Else
            Response.Write("<a href='gift_experiences.aspx?CatId=" & intCatId & "&Page=" & (intPageNumber + 1) & "'>Next >></a>")
        End If
        Response.Write("</td><td height='20' valign='middle' align='right'>")
        Response.Write("<input type='text' name='Page' value=" & intPageNumber & " style='width:25px' maxlength='3' class='TextField'>")
        Response.Write("<img src='/images/spacer.gif' width='10' height='1'>")
        Response.Write("<input type='Hidden' name='CatId' value=" & intCatId & ">")
        Response.Write("<input type='Submit' name='Paging' value='Go' style='width:25px;height:20px' class='button'>")
        Response.Write("</td></tr></table>")
        Response.Write("</form>")
        Response.Write("</td></tr>")

then how can i modify it so that it will work in ASP.NET.

When i am trying different ways so that i can use variable values like <%=intCatId%> in the body of the page, i came accross an error
'Name 'intCatId' is not declared'. How do define variables so that i can use them throughout a page.

Thx in Adv
 
Old April 5th, 2005, 12:53 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

I would get out of that approach, using Response.write in the page; Response.Write puts that code whereever it wants, and will not execute where you have it.

http://msdn.microsoft.com/library/de...jectmodel2.asp

This example isn't the greatest, but it's what I could find that had table creation in code-behind, and you can set the attributes you want there. Hope this helps.

Brian
 
Old April 6th, 2005, 05:53 AM
Registered User
 
Join Date: Mar 2005
Posts: 9
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to Anup Gavate Send a message via Yahoo to Anup Gavate
Default

Hi bmains

Look, using Response.write method, we can put whatever we want to wherever in the page depending on the constraints we provided for
the display.

I referred your link, its another way but here code just grows and grows. Can u tell me how define global variables, so that i can define them at top, assign value to them in any subroutine and can use in the body ie in any text field or in anchor tag.


 
Old April 7th, 2005, 06:44 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Using server controls in the code-behind page allows the .NET framework create the markup based on the browser control. In the code-behind, to add an element directly as is, you can use the LiteralControl class, pass in the text.

Within the code, define a variable as private:

private m_objValue as Value

You should be able to use it; though you have to maintain the value across postbacks with the viewstate, session, or cache.


Brian
 
Old April 7th, 2005, 10:43 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Quote:
quote:Originally posted by Anup Gavate
 Hi bmains

Look, using Response.write method, we can put whatever we want to wherever in the page depending on the constraints we provided for
the display.
I agree with Brian on this. Response.Write is the classic ASP way of doing things. There are ways of implementing what you want without constantly using Response.Write.

For example, in addition to literal controls you can use the panel control, embed a table within it and based upon the course of action by the user either hide it or show it.

J
 
Old April 10th, 2005, 04:11 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Anup,

I'd recommend that you play around with .NET and learn generally how it works. Then you should be able to figure out for yourself how to transfer ASP applications to .NET applications. You will undoubtedly find that there are many many better ways of doing things in .NET then there were/are in ASP.

-Peter









Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.