|
The thing is that the postback resets the page to it's original state, so any information regarding the dynamically created controls is lost. Why is that? Because the Page class is stateless. The Page recreates child controls based on the tags in the aspx files, so your controls not being present there are not shown. What you need to do is recreate the controls in the OnInit event or any event that fires before PageLoad, or in PageLoad if you do a check to see is the page is posted back. See this article[^] as an example.
regards,
Mircea
Many people spend their life going to sleep when they’re not sleepy and waking up while they still are.
|
|
|
|
|
Hello,
I have made a small project in asp 1.1 which selects the file from a directory and shows all images with the help of array and datalist. I was also able to make previous next button.
Now My problem is I want to make a auto slideshow, I don't have ajax. I don't have any idea of java too. Can any one kindly let me know how can i make it from an array of asp.net to javascript so that the slide show works. I preassume that can be done only in java.
Or is there any way I can do it in asp.net codes.
Can I also put a browse Button so that user can choose the directory he/she wants, as I am using a textbox to put the path from where it will pickup.
Sorry for my ignorance I am learing now, kindly help.
Thanks in advance
|
|
|
|
|
I will give you a couple of pointers:
If the directories are on the server, you have to build some server side control that loops over all the directories that you want the user to be able to print from, and print these to the screen.
When the user selects a directory, the server gets all the filenames from that directory and using a loop prints it into a javascript that looks for example like this:
var images = new Array(5);
images[0] = new Array('/images/','image1.jpg','Some description maybe');
images[1] = new Array('/images/','image2.jpg','Some description maybe');
images[2] = new Array('/images/','image3.jpg','Some description maybe');
images[3] = new Array('/images/','image4.jpg','Some description maybe');
images[4] = new Array('/images/','image5.jpg','Some description maybe');
So know on the client side you will have all the info to start working on your slideshow.
Now the missing element for the slideshow, is some sort of a timer, that is where the setTimeout() drops in. Once the user clicks start slideshow, he calls to a function that looks like this:
var isSlideshow = false;
function StartSlideShow()
{
isSlideshow = true;
ShowPicture (0)
}
function ShowPicture(picId)
{
if (isSlideshow) {
document.getElementById("img").src = images[i][0] + images[i][1];
setTimeout('ShowPicture(' + picId + 1 + ')',2000);
}
}
function StopSlideShow()
{
isSlideshow = false;
}
Here you should have all your ingredients to start on your slideshow.
|
|
|
|
|
let me first thank you for you help. I am sure I can do the slide show with your kind help. But I have one more question connected to it. I am using the codes below to get an save the path as well as the file name in asp.net code
For Each s in directory.GetFiles(textbox.text.trim, "*.jpeg")
How can i make the same type of array for the path and file in java.
Thanks alot again.
|
|
|
|
|
I guess you mean javascript? Look if the folders you want to browse through are on the client side, you'll have a problem, since the browser is not allowed to do things like folder browsing etc (think of the security issues that would rise with such a feature). So then indeed you need to use Java to make a small applet that would browse folders on the harddrive. I'm not a Java expert, so I don't really know.
If we talk about folders on the server, then you indeed have to loop on the serverside through all the folder and print them to the client in HTML.
|
|
|
|
|
|
postmaster@programmingknowledge.com wrote: How to upload Images to SQL Server database using ASP.NET tools.
You can't put images in to SQL Server using ASP.NET.
ASP.NET is a technology for writing web applications. It simply does not deal with the database. If you want to do anything with the database you must use ADO.NET.
postmaster@programmingknowledge.com wrote: Visit: http://www....
If you would like to advertise your website so blatantly then I suggest you buy advertising space.
|
|
|
|
|
This is for ASP.NET 1.1 but should be easy to convert to 2.0. The stored proc inserts the file into a blob/image field in the table.
Imports System
Imports System.Configuration
Imports System.Data
Imports System.Data.SqlClient
Public Class AttachmentDB
Private Function FileFieldSelected(ByVal FileField As System.Web.UI.HtmlControls.HtmlInputFile) As Boolean
If FileField.PostedFile Is Nothing Then Return False
If FileField.PostedFile.ContentLength = 0 Then Return False
Return True
End Function
Private Function GetByteArrayFromFileField(ByVal FileField As System.Web.UI.HtmlControls.HtmlInputFile) As Byte()
' Returns a byte array from the passed
' file field controls file
Dim intFileLength As Integer, bytData() As Byte
Dim objStream As System.IO.Stream
If FileFieldSelected(FileField) Then
intFileLength = FileField.PostedFile.ContentLength
ReDim bytData(intFileLength)
objStream = FileField.PostedFile.InputStream
objStream.Read(bytData, 0, intFileLength)
Return bytData
End If
End Function
Private Function FileFieldType(ByVal FileField As System.Web.UI.HtmlControls.HtmlInputFile) As String
' Returns the type of the posted file
If Not FileField.PostedFile Is Nothing Then _
Return FileField.PostedFile.ContentType
End Function
Private Function FileFieldLength(ByVal FileField As System.Web.UI.HtmlControls.HtmlInputFile) As Integer
' Returns the length of the posted file
If Not FileField.PostedFile Is Nothing Then _
Return FileField.PostedFile.ContentLength
End Function
Private Function FileFieldFilename(ByVal FileField As System.Web.UI.HtmlControls.HtmlInputFile) As String
' Returns the core filename of the posted file
If Not FileField.PostedFile Is Nothing Then _
Return Replace(FileField.PostedFile.FileName, _
StrReverse(Mid(StrReverse(FileField.PostedFile.FileName), _
InStr(1, StrReverse(FileField.PostedFile.FileName), "\"))), "")
End Function
Public Function InsertAttachment(ByVal fileID As Int32, ByVal FileField As System.Web.UI.HtmlControls.HtmlInputFile) As Int32
If Not FileFieldSelected(FileField) Then
Return -1
End If
Dim myConnection As SqlConnection = New SqlConnection(sqlconnection)
Dim myCommand As SqlCommand = New SqlCommand("uspInsertRequestAttachment", myConnection)
myCommand.CommandType = CommandType.StoredProcedure
Dim parameterID As SqlParameter = New SqlParameter("@fileID", SqlDbType.Int)
parameterID.Value = fileID
myCommand.Parameters.Add(parameterID)
Dim parameterAttachmentType As SqlParameter = New SqlParameter("@AttachmentType", SqlDbType.VarChar, 100)
parameterAttachmentType.Value = FileFieldType(FileField)
myCommand.Parameters.Add(parameterAttachmentType)
Dim parameterLength As SqlParameter = New SqlParameter("@Length", SqlDbType.Int)
parameterLength.Value = FileFieldLength(FileField)
myCommand.Parameters.Add(parameterLength)
Dim parameterUploadName As SqlParameter = New SqlParameter("@UploadName", SqlDbType.VarChar, 100)
parameterUploadName.Value = FileFieldFilename(FileField)
myCommand.Parameters.Add(parameterUploadName)
Dim parameterAttachment As SqlParameter = New SqlParameter("@Attachment", SqlDbType.Image)
parameterAttachment.Value = GetByteArrayFromFileField(FileField)
myCommand.Parameters.Add(parameterAttachment)
myConnection.Open()
myCommand.ExecuteNonQuery()
return 1
End Function
End Class
Let me know if this works for you. bgates1970
|
|
|
|
|
I'm trying to open a server side MS-Word document and present it client side. I just want the word document to appear inside the browser or open up for viewing. When I run the code I'm prompted to "Open" or "Save" the file. If I "Save" the file it is the file that I requested but if I "Open" I get the following error: "This file could not be found. Try one or more of the following: * Check the spelling of the name of the document. * Try a different file name."
Code:
Dim _webClient As New System.Net.WebClient
Dim sURI aAs String = "file://C:\test.doc"
Dim theBuffer As Byte() = _webClient.DownloadData(sURI)
With Page.Response
.ClearContent()
.ContentType = "application/msword"
.AddHeader("content-disposition", "attachement;filename=test.doc")
.OutputStream.Write(theBuffer, 0, theBuffer.Length)
.End
End With
_webClient.Dispose()
bgates1970
|
|
|
|
|
Where is the document stored?
If it's stored on the client computer, you can't load it that way. The file that you are trying to get with the DownloadData call is located on the server.
bgates1970 wrote: If I "Save" the file it is the file that I requested
Have you verified the contents of the file that you saved? I think that you will find that it's not at all the document that you have saved, but the error message.
---
b { font-weight: normal; }
|
|
|
|
|
The file I'm trying to load is located on the server (Windows 2003 SP1). I have verified that the file that I "saved" is indeed the same file.
bgates
|
|
|
|
|
Why on earth are you using a web request to open a file on the same server, then? Use the IO.File class to open it.
---
b { font-weight: normal; }
|
|
|
|
|
Hi everyone
Could anyone tell me how to get the selected text (not all text) in textarea.For example in textarea i type "Hello everyone have a nice day" .I use mouse to select just the word "day".I would like to get the value of the selected text (in this case "day").How to get it?Thanks for reading.
|
|
|
|
|
Hi,
Use
Textbox1.SelectText
property.
Hope This Works.
Nitin...
|
|
|
|
|
I m trying to visible the panel or table onmouseover event in asp.net 1.1 (which contain certain links from which i want to nevigate to other page). How can i visible the panel or table only after onmouseover the button or linkbutton or hyperlink?
plz tell any one knows!!!
-- modified at 10:02 Saturday 19th August, 2006
B.N.Thorat
9881215484
Mumbai
|
|
|
|
|
I haven't done anything particular with the onMouseOver but with the click event for a button. I'm guessing they may be similar.
btn.Attributes.Add("onClick", "javascript:alert('TEST');");
|
|
|
|
|
hi
how to do this
Upload new modules -- Each module consist of ascx (asp/net user controls) & programming script and database script – modules can be any programming/database (PHP/mySQL or ASP/mySQL or ASP/Access or PHP/Access or Asp.net/MS SQL etc etc)
– every time a new module is added the super admin can specify the programming and or database.
this is one of the point of my project specification. not getting how to do this.
thanx
|
|
|
|
|
A starter might be to look at DotNetNuke. However, it is only ASP.NET. And I'm not exactly sure how you'd put PHP into an ASCX file.
|
|
|
|
|
how we make side menu bar using asp.net1.1
omi
|
|
|
|
|
|
i already try but it is for limited time
omi
|
|
|
|
|
|
Hi,
I'm using a simple Infragistic web combo in ASP .net with code behind in VB .Net 2003. It's a very basic combo box that is working fine with code behind in C# .Net but the same code (logic) is not working in VB .Net. The problem I'm facing is that when I click on button1 and in it's event I simply write:
WebCombo2.SelectedRow.Cells(0).Value.ToString()
and it returns with a null object reference exception. When I debugged, I found the SelectedRow object null.
I'm using:
-> Infragistics NetAdvantage 2006 Volume 2 CLR 1.x
-> VS 2003 ASP .Net, code behind in VB .Net
here is the code:
<igcmbo:webcombo id="WebCombo2" runat="server" Height="20px"
DataValueField="User_Id" DataTextField="Logon_Name" Width="200px" Font-Names="Verdana" DataMember="User" Font-Size="8pt" BorderStyle="Solid" BorderWidth="1px" SelBackColor="LightSteelBlue" BackColor="White" ForeColor="Black" SelForeColor="51, 51, 51" Version="2.00" BorderColor="Gainsboro">
<Columns>
<igtbl:UltraGridColumn
HeaderText="User Id" Key="User_Id" IsBound="True" BaseColumnName="User_Id">
<Footer
Key="User_Id"></Footer>
<Header Key="User_Id"
Caption="User ID"></Header>
</igtbl:UltraGridColumn>
<igtbl:UltraGridColumn
HeaderText="Logon Name" Key="Logon_Name" IsBound="True"
BaseColumnName="Logon_Name">
<Footer
Key="Logon_Name"></Footer>
<Header
Key="Logon_Name" Caption="Logon Name"></Header>
</igtbl:UltraGridColumn>
</Columns>
<DropDownLayout DropdownWidth="450px"
BorderCollapse="Separate" AllowColSizing="Free" RowHeightDefault="20px"
HeaderClickAction="Select"
RowSizing="Free" DropdownHeight="180px" TableLayout="Fixed"
AllowRowSizing="Free">
<RowStyle BorderWidth="1px"
Font-Size="8pt" Font-Names="Verdana" BorderColor="Gainsboro"
BorderStyle="Solid"
BackColor="White"
Height="18px">
<Padding Left="5px"
Right="5px"></Padding>
</RowStyle>
<SelectedRowStyle
ForeColor="White" BackColor="SteelBlue">
<Padding Left="5px"
Right="5px"></Padding>
</SelectedRowStyle>
<HeaderStyle
VerticalAlign="Middle" BorderWidth="1px" Font-Size="8pt" Font-Names="Verdana"
BorderColor="White"
BorderStyle="Solid"
HorizontalAlign="Left" BackColor="LightSteelBlue">
<Padding Left="3px"
Right="3px"></Padding>
</HeaderStyle>
<RowAlternateStyle
BackColor="#E0E0E0"></RowAlternateStyle>
<FrameStyle Width="450px"
Cursor="Default" BorderWidth="1px" Font-Size="8pt" Font-Names="Verdana"
BorderStyle="None"
BackColor="Gainsboro" Height="180px"></FrameStyle>
</DropDownLayout>
<ExpandEffects
ShadowColor="LightGray"></ExpandEffects>
</igcmbo:webcombo>
<asp:Button id="Button1" style="Z-INDEX: 101; LEFT: 152px; POSITION:
absolute; TOP: 56px" runat="server" Text="Button"></asp:Button>
I'm binding the Infragistic webCombo to a DataSet.
Plz help,
Thanks.
|
|
|
|
|
HI,
hw r u all,i have a problem ,i have a website that i made in asp.net and vb.net.in this website i want to uppload image on my websever folder name as "Images",and that images i displayed in my datagrid..locally on my machine its working well,bt no i want to test it on my webserver,tell me how can i athunticate against the username and password that my webserver used to uplaod files,here ist he code that i locally use
Dim f_info As New FileInfo(UploadFile.Value)
If f_info.Extension = ".bmp" Or f_info.Extension = ".gif" Or f_info.Extension = ".jpg" Then
Dim f_name As String = System.IO.Path.GetFileName(UploadFile.Value)
'f_name=f_name.Replace(f_name.Substring(0,f_name.
Dim insert_path As String = "images/" + f_name
Dim save_location As String = Server.MapPath("../images" + "/" + f_name)
'Dim phy_location As String = Request.PhysicalPath
UploadFile.PostedFile.SaveAs(save_location)
Image_SaveToDBURL(insert_path).
tell me how can i uplaod image on the webserver through proper Authentication
kindly help me in this regard
|
|
|
|
|