Click here to Skip to main content
15,907,328 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: How to disable the back button and backspace key using Javascript..? Pin
Sathesh Sakthivel3-Sep-07 23:48
Sathesh Sakthivel3-Sep-07 23:48 
AnswerRe: How to disable the back button and backspace key using Javascript..? Pin
Sandeep Akhare4-Sep-07 0:00
Sandeep Akhare4-Sep-07 0:00 
Questionproblem on genaration of unique number Pin
biswa473-Sep-07 23:43
biswa473-Sep-07 23:43 
AnswerRe: problem on genaration of unique number Pin
Fred_Smith4-Sep-07 1:21
Fred_Smith4-Sep-07 1:21 
AnswerRe: problem on genaration of unique number Pin
Pete O'Hanlon4-Sep-07 3:08
mvePete O'Hanlon4-Sep-07 3:08 
QuestionRe: problem on genaration of unique number Pin
biswa474-Sep-07 18:12
biswa474-Sep-07 18:12 
Questionassembly error Pin
saqib823-Sep-07 23:24
saqib823-Sep-07 23:24 
AnswerRe: assembly error Pin
Sathesh Sakthivel3-Sep-07 23:44
Sathesh Sakthivel3-Sep-07 23:44 
saqib82 wrote:
what are the reasons for that error.


(1) Common mistake when working with code behind classes.

Remember! Codebehinds arn't handled the same way as inline/ pages!

You need to declare EVERY control you want to interact with in the codebehind class

Do this just after the Inherits statement:

<code>Public Class PageOne
Inherits System.Web.UI.Page

Protected WithEvents litOne As System.Web.UI.WebControls.Literal

...</code>


(2) Bad Scoping.

<code>Sub Page_Load(ByVal e As System.EventArgs) Handles MyBase.Load

Private strHello As String

End Sub

Sub Button1_Click(ByVal e As System.EventArgs) Handles Button1.Click

strHello = "Hello!"

End Sub</code>

(3) bad inits and constructs:

Remember, some classes have constuctors

Consider DirectoryInfo:
<code>Sub Page_Load() ....

Dim dirInfo As System.IO.DirectoryInfo

dirInfo.GetDirectory("C:\")

End Sub</code>

In the above example, we've only defined dirInfo *AS* a DirectoryInfo class, we haven't actually created it

So we need to do this instead:

<code>Sub Page_Load() ....

Dim dirInfo As System.IO.DirectoryInfo

dirInfo = New System.IO.DirectoryInfo("C:\")

End Sub</code>

That should do it....

Remember, ALWAYS refer to the MSDN Library when enquiring about classes and their initilisation (sp?) methods.... why trust some "1337 script kiddie!" site when you've got the official reference at http://www.msdn.com ? Or better yet, get the compiled version on CD, don't need to worry about long download times or the constant "was this article of any use to you?" screen.

HTH
-1337_d00d





<div class="ForumSig">SSK.</div>
QuestionASP.Net with Sharepoint Pin
ScottM13-Sep-07 22:53
ScottM13-Sep-07 22:53 
QuestionError when compilation - Urgent Help Pin
morteza573-Sep-07 22:46
morteza573-Sep-07 22:46 
AnswerRe: Error when compilation - Urgent Help Pin
VenkataRamana.Gali4-Sep-07 0:46
VenkataRamana.Gali4-Sep-07 0:46 
AnswerRe: Error when compilation - Urgent Help Pin
nandhububbly4-Sep-07 2:01
nandhububbly4-Sep-07 2:01 
GeneralRe: Error when compilation - Urgent Help Pin
morteza574-Sep-07 3:44
morteza574-Sep-07 3:44 
QuestionDatalist inside datalist Pin
IamAmit3-Sep-07 22:42
IamAmit3-Sep-07 22:42 
AnswerRe: Datalist inside datalist Pin
Sandeep Akhare6-Sep-07 0:34
Sandeep Akhare6-Sep-07 0:34 
QuestionHow to find IP address of user machine in ASP. Pin
rahul.net113-Sep-07 22:36
rahul.net113-Sep-07 22:36 
AnswerRe: How to find IP address of user machine in ASP. Pin
Fred_Smith3-Sep-07 23:19
Fred_Smith3-Sep-07 23:19 
GeneralRe: How to find IP address of user machine in ASP. Pin
rahul.net114-Sep-07 0:02
rahul.net114-Sep-07 0:02 
GeneralRe: How to find IP address of user machine in ASP. Pin
Fred_Smith4-Sep-07 0:19
Fred_Smith4-Sep-07 0:19 
GeneralRe: How to find IP address of user machine in ASP. Pin
rahul.net114-Sep-07 1:07
rahul.net114-Sep-07 1:07 
GeneralRe: How to find IP address of user machine in ASP. Pin
Fred_Smith4-Sep-07 1:10
Fred_Smith4-Sep-07 1:10 
GeneralRe: How to find IP address of user machine in ASP. Pin
rahul.net114-Sep-07 1:27
rahul.net114-Sep-07 1:27 
GeneralRe: How to find IP address of user machine in ASP. Pin
Fred_Smith4-Sep-07 1:32
Fred_Smith4-Sep-07 1:32 
GeneralRe: How to find IP address of user machine in ASP. Pin
rahul.net114-Sep-07 1:50
rahul.net114-Sep-07 1:50 
AnswerRe: How to find IP address of user machine in ASP. Pin
Sathesh Sakthivel3-Sep-07 23:35
Sathesh Sakthivel3-Sep-07 23:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.