|
Here is the code,
Protected Sub LoadFileFolders(ByVal FileFolderPath As String, Optional ByVal _FileType As FileType = FileType.Folder)
If _FileType = FileType.File Then
Dim HtmlString As New StringBuilder
HtmlString.Append("<iframe width=""100%"" height=""100%"" frameborder=""0""")
HtmlString.Append(" src=""" & FileFolderPath & """>" & vbCrLf)
HtmlString.Append("</iframe>" & vbCrLf)
Dim LblContent As New Label
LblContent.Text = HtmlString.ToString
PnlFoldersFiles.Controls.Clear()
PnlFoldersFiles.Controls.Add(LblContent)
Else
Dim TblMain As New Table
Dim TrMain As TableRow
Dim TcMain As TableCell
TblMain.CellPadding = 2
TblMain.CellSpacing = 2
TblMain.BorderWidth = 0
Dim _Dir As New IO.DirectoryInfo(FileFolderPath)
Dim _DirectoryInfo() As IO.DirectoryInfo = _Dir.GetDirectories
Dim ICount As Integer = 0
Dim LkbFolder As LinkButton
For Each _D As IO.DirectoryInfo In _DirectoryInfo
LkbFolder = New LinkButton
TrMain = New TableRow
TcMain = New TableCell
TcMain.Text = "<img src=""images/folderClosed.gif"" />"
TrMain.Cells.Add(TcMain)
TcMain = New TableCell
LkbFolder.ID = "Lkb_Folder" & ICount
LkbFolder.Text = _D.Name
TcMain.Controls.Add(LkbFolder)
AddHandler LkbFolder.Click, AddressOf FolderFile_Click
TrMain.Cells.Add(TcMain)
TblMain.Rows.Add(TrMain)
ICount += 1
Next
_Dir = New IO.DirectoryInfo(FileFolderPath)
Dim LkbFile As LinkButton
For Each _File As IO.FileInfo In _Dir.GetFiles
Dim _Ext As String = _File.Extension
Dim FileImage As String = "unknownimg.gif"
Select Case _Ext
Case ".htm", ".html", ".mht"
FileImage = "htmlimg.gif"
Case ".asp"
FileImage = "aspimg.gif"
Case ".aspx"
FileImage = "aspximg.gif"
Case ".resx"
FileImage = "resximg.gif"
Case ".vbproj"
FileImage = "vbprojimg.gif"
Case ".vb"
FileImage = "aspxvbimg.gif"
Case ".asa", ".asax", ".webinfo"
FileImage = "asaimg.gif"
Case ".pdf"
FileImage = "pdfimg.gif"
Case ".config"
FileImage = "configimg.gif"
Case ".vsdisco"
FileImage = "vsdiscoimg.gif"
Case ".sln"
FileImage = "solimg.gif"
Case ".txt"
FileImage = "textimg.gif"
Case ".gif"
FileImage = "gifimg.gif"
Case ".jpg", ".jpeg"
FileImage = "jpgimg.gif"
Case ".dll", ".ocx"
FileImage = "dllimg.gif"
Case ".pdb"
FileImage = "pdbimg.gif"
Case ".mdb"
FileImage = "mdbimg.gif"
Case ".doc"
FileImage = "docimg.gif"
Case ".inc"
FileImage = "incimg.gif"
Case ".xls", ".csv"
FileImage = "excelimg.gif"
Case ".sql"
FileImage = "sqlimg.gif"
Case ".zip"
FileImage = "zipimg.gif"
Case ".exe"
FileImage = "exeimg.gif"
Case ".bmp"
FileImage = "bmpimg.gif"
Case ".js", ".vbs"
FileImage = "scriptimg.gif"
Case ".pps", ".ppt"
FileImage = "pptimg.gif"
End Select
TrMain = New TableRow
TcMain = New TableCell
TcMain.Text = "<img src=""images/" & FileImage & """ />"
TrMain.Cells.Add(TcMain)
LkbFile = New LinkButton
TcMain = New TableCell
LkbFile.Text = _File.Name
LkbFile.ID = "Lkb_File" & ICount
AddHandler LkbFile.Click, AddressOf FolderFile_Click
TcMain.Controls.Add(LkbFile)
TrMain.Cells.Add(TcMain)
TblMain.Rows.Add(TrMain)
ICount += 1
Next
PnlFoldersFiles.Controls.Add(TblMain)
End If
End Sub
Here PnlFoldersFiles is the Right side Pane (Panel)
Additionally I have the Click Event separately. I believe you don't need that event.
|
|
|
|
|
Hi,
You should create an handlere to handle event of linkbutton and assign that handler to the click event of dynamically generated linkbuttons at runtime.
Have a look at following.
The following is the handler to handle command event of your link button.
Command event will fire when u click on the linkbutton.
We consider command event because in this event you can differentiate which linkbutton is clicked and depend on commandname and commandargument you can execute accordingly.
protected void lnk_Command ( object sender, CommandEventArgs e )
{
string strCommand = e.CommandName;
string strArgument = e.CommandArgument;
}
In the following code I m creating a linkbutton dynamically, assigning ID, CommandName, CommandArgument and EventHandler to it.
LinkButton Lnk = new LinkButton();
Lnk.ID = "ID";
Lnk.CommandName = "urcommandName";
Lnk.CommandArgument = "urCommandargument";
Lnk.Command +=new CommandEventHandler(lnk_Command);
This way you can create as many linkbuttons and assign unique commandargument and commandname to each of them.
I hope this will help you.
Thanks and Regards,
Chetan Ranpariya
|
|
|
|
|
Did you said,
Chetan Ranpariya wrote: Lnk.Command +=new CommandEventHandler(lnk_Command);
I am afraid, LinkButton does not have a Property/Method as Command. Its an Event, where we can't assign by direct method.
I have already added the Click Event for that LinkButton using AddHandler method. If you want to know more about the code see that code I posted for the previous reply.
|
|
|
|
|
Hi,
I applogize for not seeing your code properly.
Command is not a property/method of linkbutton but its an event and u can use addhandler method for it as u do with the click event.
I suggested the command event not the click event because in command event u can decide what code to execute depend on the commandname and commandargument.
but if u want to use click event then that's fine.
According to my observation of your code it is correct and as u r adding handler for each of the linkbutton it should work fine.
There may be some other problem. Did u tried by debugging or puting some output statement in the event handler?
Thanks and Regards,
Chetan Ranpariya
|
|
|
|
|
Chetan Ranpariya wrote: I applogize for not seeing your code properly.
Its ok.
Chetan Ranpariya wrote: Did u tried by debugging or puting some output statement in the event handler?
Yes. I do have. Additionally I added another table with the same logic to load the files, and added LinkButton with the Click event. There the event is firing. I don't understand why?
|
|
|
|
|
hi all,
I have created a web application project in asp.net 2.0 and i have created the .msi installable file using the web deployment method of VS 2005.
I installed the project and tried to run it using the virtual directory name i gave during the installation process.
I got the parser error as
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: Could not load type 'SampleDemo._Default'.
Source Error:
Line 1: <%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="SampleDemo._Default" %>
Line 2:
Line 3:
Source File: /deploydemo/default.aspx Line: 1
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.210
then I came to know that the .DLL file in not extracted into the bin folder instead its been extracted to the main folder where other aspx files been extracted.
I need to solve this problem.
When we follow the steps in VS 2003 its working good.but in 2005 the .DDL file has been extracted to main folder.I don't know its there any problem in the steps i have executed OR its the default procedure of VS 2005 .
can any one solve this problem
PS:. i need .DLL must be extracted to bin folder.because we ll give that .msi file to our client.it should be in working condition if we execute the .msi file.
thanks in advance
Senthilraj K
|
|
|
|
|
Hi,
i have an asp.net application which has pages in different folders like
supervisors, managers etc.
and each folder has n number of pages(aspx). it is finding difficulty for me to check the user rights for each page. so is it possible to restrict the user if he does not have the manager rights to all the pages in the manager folder?
Please help.
Biju S
|
|
|
|
|
You must have a list of users, roles and UserRoles. You will have to use windows security to load the roles for the current user. Then ;
protected void Page_Load(object sender, EventArgs e)
CheckRole()
{
if(!IsPostBack)
{
//Do Something
}
public void CheckRole()
{
if (!Context.User.IsInRole("Manager"))
{
thow new Exception("Access Denied");
}
}
}
You can usethe windows security using the following:
using System.Security.Principal;
and then
IIdentity identity;
String[] roles = {"manager","employee"};
GenericPrincipal g = new GenericPrincipal(identity, roles);
You will have to fix the IIdentity part above.
|
|
|
|
|
only two letters away from being an asset
|
|
|
|
|
Use the web.config file to set security for the folders, similar to below
<configuration>
<location path="Folder1">
<system.web>
<authorization>
<deny roles="group"/>
<allow roles="admin"/>
<allow users="?"/>
</authorization>
</system.web>
</location>
</configuration>
only two letters away from being an asset
|
|
|
|
|
I create a datable in the event of button1
how can I use it in the event of button2? please help me
I do this :
in button1
Session["temptable"]=dt;
in button2
dt=(DataTable)Session["temptable"];
when I debug it
messege show it is not exit dt in event of button2
|
|
|
|
|
Your question makes no sense. Are you sure the table does not exist ? dt is null, or you get a message that the variable does not exist ? If the latter, then you're in release mode.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Put the datatable in the session again and then use it in the cleck event of the second button.
Apurva Kaushal
|
|
|
|
|
good day everyone..
again i need your help... on how to include my separate report made from crystal report 9 to asp.net 2003?
pls send me link on where i could use as a refenrence.... thank you...
start a new beginning in every ending; thats what life for......
|
|
|
|
|
|
Hi all,
I'm a programmer in Web developer with ASP.NET 2.0, C# basic. I have this issue and it cost me lots of time on investigating the solution. Let me explain the scenario in the easiest way to understand. Let say i have site A and site B, both of them have Response.Cache.SetCacheability(NoCache), reason of disable caching is prevent user from hitting back button to go back to their previous viewed pages after they signed out. And i succeed in this prevention. But i've got the issue of Page has expired. When i deal with surfing like go to Page A, then B, then hit back button to Page A, then back button to B again and again, there's nothing happen because they are 2 different pages. but when i work on Page A only, let say i have a multiview menu in Page A, then i switch from tab X to tab Y, then hit back button, that throw Page has expired. Im so sick with this. As far as i know that because the post back url point to the same page, and this is just a warning from IE from duplicating request to one page, but this is disturbing end user a lot. Is there any work around this?
Please assist me on this, any of your solutions are appreciated.
Thank you very much.
-- modified at 19:58 Thursday 14th June, 2007
I moved this to the ASP.NET forum, please in future respect the notice that says 'do not post programming questions in the lounge'.
There is no END ROAD in the world, the end of this road is the beginning of another road...
|
|
|
|
|
Hi, I have made changes to my code according to the responses I was getting the last time I post a question about the exception " Object reference not set to an instance of an object". I still get the same exception after the changes. It's saying that the line
strGoodPassword = CType(myCommand.ExecuteScalar, String)
is the cause of the problem. I don't know what else to to, please take a look at my code below. Thank you in advance for your help.
Private Sub lblRegister_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblRegister.Click
Dim bResult As Boolean = False
Dim myConnection As OdbcConnection
Dim myCommand As OdbcCommand
Dim strInsert As String
Dim strGoodPassword As String
Dim strSQL As String
strSQL = String.Empty
myConnection = New OdbcConnection("Driver={MySQL ODBC 3.51 Driver};Server=localhost;Database=myDb;User=myUSERassword=myPW;Option=3;")
strSQL = String.Format("SELECT myUserName FROM myTable WHERE (email='{0}');", txtUserName.text)
myConnection.Open()
strGoodPassword = CType(myCommand.ExecuteScalar, String)
If Not strGoodPassword Is Nothing Then
If strGoodPassword = txtUserName.Text Then
bResult = True
Else
lblMessage.Text = "That user name is already taken!"
lblMessage.Text &= " Please choose another user name."
End If
Else
lblMessage.Text = "That user name is already taken!"
lblMessage.Text &= " Please choose another user name."
End If
strInsert = "INSERT into membersinfotbl (FirstName,LastName,Password,Phone,Email,Profession,StrAddress,City,State,ZipCode)value (?,?,?,?,?,?,?,?,?,?)"
myCommand As New OdbcCommand(strInsert,myConnection)
myCommand.Parameters.Add("@FirstName", txtFirst.Text)
myCommand.Parameters.Add("@LastName", txtLast.Text)
myCommand.Parameters.Add("@Password", txtPassword.Text)
myCommand.Parameters.Add("@Phone", txtPhone.Text)
myCommand.Parameters.Add("@Email", txtEmail.Text)
myCommand.Parameters.Add("@Profession", txtProfession.Text)
myCommand.Parameters.Add("@StrAddress", txtAddress.Text)
myCommand.Parameters.Add("@City", txtCity.Text)
myCommand.Parameters.Add("@State", txtState.Text)
myCommand.Parameters.Add("@ZipCode", txtZipCode.Text)
myCommand.ExecuteNonQuery()
myConnection.Close()
End Sub
-- modified at 20:03 Thursday 14th June, 2007
|
|
|
|
|
If you post 20 lines of code, tell us which one has the error
ASPnoob wrote: strSQL = String.Format("SELECT myUserName FROM myTable WHERE (email='{0}');", txtUserName.text)
You need to read up on SQL injection attacks. Odds are good that if you give me the URL of this site, I can delete your entire database.
I can't see which line could fail, let us know where to look.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
It's saying that the following line is the cause of the problem.
strGoodPassword = CType(myCommand.ExecuteScalar, String)
Thanks for helping.
|
|
|
|
|
Where do you intialize myCommand? Of course it will give a null reference exception if you haven't done so before attempting to use it.
only two letters away from being an asset
|
|
|
|
|
I have initialized myCommand but now I'm having other error messages. Would you please look at the code to see if the logic is it self the problem. Basically what I'm trying to do is validate the username before sending it to the database for storage. The code checks to see whether the username is already in existence or not. If it is then an error message is given, if not the username is sent to the database. Would you please look at the code to see if it even make logical sense. The code may not reflect what I want. Thanks for your help.
-- modified at 1:06 Friday 15th June, 2007
|
|
|
|
|
What are that other error messages and at which line?
Thanks and Regards,
Chetan Ranpariya
|
|
|
|
|
You are not initilizing the object of OdbcCommand class,
Before calling ExecuteScalar function ,right this statement,
myCommand=new OdbcCommand(strsql,myConnection)
Always remember,object reference not set to instance of object is exception throws whenever u r trying to use an object which is not initialized.
Send me reply if ut problem gets solved.
GIRISH
|
|
|
|
|
I think there is error in ur insert query,
it is Insert into table_name(columns) <b>values</b>
u have written value,this might be the proble.
If that doesnt wotks try the code given below,
Still if it is not working send me reply.
Private Sub lblRegister_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblRegister.Click
Dim bResult As Boolean = False
Dim myConnection As OdbcConnection
Dim myCommand As OdbcCommand
Dim strInsert As String
Dim strGoodPassword As String
Dim strSQL As String
strSQL = String.Empty
myConnection = New OdbcConnection("Driver={MySQL ODBC 3.51 Driver};Server=localhost;Database=myDb;User=myUSERassword=myPW;Option=3;")
strSQL = String.Format("SELECT myUserName FROM myTable WHERE (email='{0}');", txtUserName.text)
myCommand =new OdbcCommand("SELECT myUserName FROM myTable WHERE email='" & txtUserName.text &"'")
myConnection.Open()
strGoodPassword = CType(myCommand.ExecuteScalar, String)
If Not strGoodPassword Is Nothing Then
If strGoodPassword = txtUserName.Text Then
bResult = True
Else
lblMessage.Text = "That user name is already taken!"
lblMessage.Text &= " Please choose another user name."
End If
Else
lblMessage.Text = "That user name is already taken!"
lblMessage.Text &= " Please choose another user name."
End If
strInsert = "INSERT into membersinfotbl (FirstName,LastName,Password,Phone,Email,Profession,StrAddress,City,State,ZipCode)value (?,?,?,?,?,?,?,?,?,?)"
myCommand As New OdbcCommand("INSERT into membersinfotbl (FirstName,LastName,Password,Phone,Email,Profession,StrAddress,City,State,ZipCode) values ('" & txtFirst.Text & "','" & txtLast.Text & "','" & txtPassword.Text & "','" & txtPhone.Text & "','" & txtEmail.Text & "','" & txtProfession.Text & "','" & txtAddress.Text & "','" & txtCity.Text & "','" & txtState.Text & "','" & txtZipCode.Text & "')",myConnection)
myConnection.Close()
End Sub
GIRISH
|
|
|
|
|
Thanks for responding to my post, however, your code has a few problems in it. VS2003 gave four error messages on the the following line.
myCommand As New OdbcCommand("INSERT into membersinfotbl (FirstName,LastName,Password,Phone,Email,Profession,StrAddress,City,State,ZipCode) values ('" & txtFirst.Text & "','" & txtLast.Text & "','" & txtPassword.Text & "','" & txtPhone.Text & "','" & txtEmail.Text & "','" & txtProfession.Text & "','" & txtAddress.Text & "','" & txtCity.Text & "','" & txtState.Text & "','" & txtZipCode.Text & "')",myConnection)
The messages are "Expression is not a method"
"Expression expected"
"Method arguments must be enclosed in parentheses"
"End of statement expected"
|
|
|
|
|