Jump to content
Xtreme .Net Talk

Declaring a variable in aspx page and assigning the value in code behing ASP.Net


Recommended Posts

Posted

Developed a web application in ASP.Net (Framework 1.0), in which I have used public variable

 

which is defined in the aspx page and in the code behind will have some calculations and the

 

assign some value to that variable.

 

Example:

reports.aspx

.....

<TABLE cellSpacing="2" cellPadding="0" width="700" align="center">

<%=tstrHTML%>

</TABLE>

.....

 

reports.aspx.vb

private void displayReports()

{

tstrHTML = "<tr><td align=left>First Name</td>" & _

"<td align=left>Last Name</td>" & _

"<td align=left>Salary</td>"

 

tstrHTML += "<tr><td align=left>Binny</td>" & _

"<td align=left>Federal</td>" & _

"<td align=left>230000</td>"

 

}

 

The application was running fine for the last couple of years and all of a sudden having some

 

problem.

 

Can any one of you help me on figuring out this issue.

 

Thanks

Posted

What is the error message?

 

Nothing is being displayed in the table?

 

From the snippet you posted, I can tell you need to end your table rows....

 

"<td align=left>Salary</td></tr>"

 

"<td align=left>230000</td></tr>"

 

You didn't post the declaration of tstrHTML,but it should have a scope of at least Friend.

Posted
What is the error message?

 

Nothing is being displayed in the table?

 

From the snippet you posted, I can tell you need to end your table rows....

 

"<td align=left>Salary</td></tr>"

 

"<td align=left>230000</td></tr>"

 

You didn't post the declaration of tstrHTML,but it should have a scope of at least Friend.

 

Yep think you need to include the tstrHTML declaration and where displayReports is called.

 

As an aside both the </td> and </tr> tags are optional. You can save a bit of bandwidth by not including them. However, I always use them myself.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...