|
plzz tell how file is uploaded using browser button on page. it means write code to read file,upload and browse button & write code to save and selected file to browser....
|
|
|
|
|
please put his code in html site and manage yourself where ever you want to save your file there is method for saveing file.
Cool
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="aaaaaa.aspx.vb" Inherits="civilesengineers.aaaaaa"%><br />
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><br />
<HTML><br />
<HEAD><br />
<title>aaaaaa</title><br />
<script runat="server" id="Script1"><br />
Private Function PickupFileNameWithExtasion(byval sttr as string) as String<br />
Dim st As String = Trim(sttr)<br />
Dim sr As String<br />
dim cs as String<br />
Dim f, k As Integer<br />
sr = StrReverse(st)<br />
f = InStr(sr, "\")<br />
k = f - 1<br />
cs = StrReverse(Mid(sr, 1, k))<br />
PickupFileNameWithExtasion = cs<br />
<br />
End Function<br />
<br />
<br />
Sub UploadBtn_Click(Sender as Object, e as EventArgs)<br />
dim strLocalPath as string<br />
dim strFileName as string<br />
dim i as integer=2<br />
Dim popUpScript As String<br />
if MyFile.PostedFile.FileName <> "" then<br />
strFileName = PickupFileNameWithExtasion(MyFile.PostedFile.FileName)<br />
<br />
MyFile.PostedFile.SaveAs(ConfigurationSettings.AppSettings("MyPath")& strFileName)<br />
<br />
<br />
Else <br />
End if<br />
End Sub<br />
</script><br />
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1"><br />
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1"><br />
<meta name="vs_defaultClientScript" content="JavaScript"><br />
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5"><br />
</HEAD><br />
<body bgColor="inactivecaptiontext" MS_POSITIONING="GridLayout"><br />
<form id="Form1" action="aaaaaa.aspx" method="post" encType="multipart/form-data" runat="server"><br />
<h1 align="center">Upload Your File</h1><br />
<P align="center"> </P><br />
<P align="center">Selec<br />
<asp:LinkButton id="LinkButton1" style="Z-INDEX: 101; LEFT: 32px; POSITION: absolute; TOP: 208px"<br />
runat="server" Width="77px" Height="24px">New User</asp:LinkButton>t File <br />
To Upload to Server: <input id="MyFile" type="file" size="23" name="MyFile" runat="server"> <br />
<input id="Submit1" type="submit" value="Upload!" name="Submit1" runat="server" OnServerclick="UploadBtn_Click"><br />
<asp:LinkButton id="LinkButton2" style="Z-INDEX: 102; LEFT: 40px; POSITION: absolute; TOP: 176px"<br />
runat="server" Width="43px" Height="16px">Login</asp:LinkButton><br />
<asp:LinkButton id="LinkButton3" style="Z-INDEX: 103; LEFT: 32px; POSITION: absolute; TOP: 256px"<br />
runat="server" Width="87px" Height="24px">Emp Longin</asp:LinkButton><br />
<asp:LinkButton id="LinkButton4" style="Z-INDEX: 104; LEFT: 40px; POSITION: absolute; TOP: 288px"<br />
runat="server" Width="93px" Height="24px">NewEmployye</asp:LinkButton><br />
</P><br />
</form><br />
</body><br />
</HTML>
Pavan Pareta
|
|
|
|
|
manish srivastava wrote: it means write code to read file,upload and browse button & write code to save and selected file to browser....
It seems you want CP to do all what you need, then what else would you do? Just copy/paste like Mark said in the other post? Oh boy, you are loosing your fun of writing code and being a programmer shouldn't appear in your mind.
|
|
|
|
|
Sorry, this is a double post, I forgot to make it ignore HTML tags.
This is probably a more involved question, but if you can atleast give me the bullet points. I want be able to have a web user control that gets used something like this
<cc:MyControl id="MyControl1" runat="server">
<Fields>
<Field dbname="name" header="Full Name">
<Field dbname="Address1" header="Address 1">
...
</Fields>
<EmailRecipients>
<Recipient address="someone@somewhere.com">
<Recipient address="someelse@somewhere.com">
...
</EmailRecipients>
</cc:MyControl>
I then want to be able in the code behind have access the Fields and the EmailRecipients. I also want Intelisense to work. You see this behavior with controls like the GridView control.
Thanks,
Matt
|
|
|
|
|
This is probably a more involved question, but if you can at least give me the bullet points. I want be able to have a web user control that gets used something like this
<cc:MyControl id="MyControl1" runat="server">
<Fields>
<Field dbname="name" header="Full Name">
<Field dbname="Address1" header="Address 1">
...
</Fields>
<EmailRecipients>
<Recipient address="someone@somewhere.com">
<Recipient address="someelse@somewhere.com">
...
</EmailRecipients>
</cc:MyControl>
I then want to be able in the code behind have access the Fields and the EmailRecipients. I also want Intelisense to work. You see this behavior with controls like the GridView control.
Thanks,
Matt
|
|
|
|
|
In the web user control, you can simply define the collection properties for Fields and EmailRecipients like:
private List<Field> _fields = new List<Field>();
[PersistenceMode(PersistenceMode.InnerProperty)]
public List<Field> Fields
{
get
{
return _fields;
}
}
The source code of Field class should be defined in the App_Code or a seperate project.
|
|
|
|
|
I set up a simple test project for this. Adding the public List property to the control does make intelisense recognize MyFields, but it doesn't think anything should be inside the MyFields tags (Validation (ASP.Net): Text is not allowed between the opening and closing tags for element MyFields'.
What else do I need to do?
Web User Control Class
public partial class MyControl : System.Web.UI.UserControl
{
private List<MyField> _MyFields = new List<MyField>();
[PersistenceMode(PersistenceMode.InnerProperty)]
public List<MyField> MyFields
{
get
{
return _MyFields;
}
set
{
_MyFields = value;
}
}
protected void Page_Load(object sender, EventArgs e)
{
}
}
MyField class, located in the App_Code folder
public class MyField
{
string _MyProperty;
public string MyProperty
{
get
{
return _MyProperty;
}
set
{
_MyProperty = value;
}
}
public MyField()
{
}
}
|
|
|
|
|
In addition to the fact that you have to register the tagname and tagprefix for the web user control, you also register the namespace and tagprefix for the MyField so that the ASP.NET parser can recognize the tag. The registration markup should be something like:
<%@ Register Src="MyControl.ascx" TagName="MyControl" TagPrefix="uc1" %>
<%@ Register TagPrefix="uc1" Namespace="ASP" %> Assuming the MyField class is not wrapped up in any namespace in the App_Code, and the default namespace ASP is used. If you define it in your namespace, you simply replace the ASP with your own one.
|
|
|
|
|
That got me a step closer. uc1:MyField now shows up in intelisense. However the build fails saying that Unknown server tag 'uc1:MyField'. I am not using any custom namespaces
This is my markup
<uc1:MyControll ID="MyControll1" runat="server">
<MyFields>
<uc1:MyField MyProperty="This" />
<uc1:MyField MyProperty="That" />
<uc1:MyField MyProperty="You" />
</MyFields>
</uc1:MyControll>
This is my register tags
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register Src="MyControll.ascx" TagName="MyControll" TagPrefix="uc1" %>
<%@ Register TagPrefix="uc1" Namespace="ASP"%>
Thoughts?
|
|
|
|
|
You now simply define the MyField in a namespace and replace the ASP with that value. My mistake here is that the default namespace of the MyField class will be empty, not ASP like the dynamic of the web pages, and the Namespace attribute of the Regsiter directive does not allow an empty value, sorry about this. Also, I'm not sure if you know this fact or not, but when you switch to the Design view you will see the the designer reports the error on the web user control. The only way to work around this error is to use a custom web control.
|
|
|
|
|
The designer error is kind of annoying. Does anyone know to work around that? I made this a server control and have it working like i want. The class is inheriting from CompositeControl, I even added a Designer class and handled the GetDesignErrorHTML override, or whatever its called, and I still get the error. Its not serious as it still compiles and functions as expected, but it looks rather unprofessional.
|
|
|
|
|
Yeah, it's quite annoying as far as the design support is concerned, and afaik this is the limitation of the product in supporting the web user control at design time. The parser always looks at the UserControl class when a web user control is placed in the web page while it should look at the real control or at least the base class of the web user control.
|
|
|
|
|
plzz write a simple function how to make a e-mail function in asp.net.
the function should accept, to, from,subject & message string and send e-mail using ASP.NET.
|
|
|
|
|
Ok, I finished it. Now what?
|
|
|
|
|
ednrgc wrote: Ok, I finished it. Now what?
|
|
|
|
|
There you go, enjoy
=============================================
using System.Net.Mail;
public static void SendMailMessage(string sMailBody, string sFromAddress, string sFromName,
string[] sToAddress, string[] sCC, string[] sBCC, string sSubject, bool IsHTML)
{
SmtpClient objSMTPClient = new SmtpClient("localhost");
MailMessage objMessage = new MailMessage();
try
{
MailAddress objFromAddress = new MailAddress(sFromAddress, sFromName);
// From address will be given as a MailAddress Object
objMessage.From = objFromAddress;
// To address collection of MailAddress
for (int i = 1; i <= sToAddress.Length; i++)
{
objMessage.To.Add(sToAddress[i - 1]);
}
// CC and BCC optional
// MailAddressCollection class is used to send the email to various users
// You can specify Address as new MailAddress("user@host.com")
if (sCC != null)
{
if (sCC.Length > 0)
{
for (int i = 1; i <= sCC.Length; i++)
{
objMessage.CC.Add(sCC[i - 1]);
}
}
}
if (sBCC != null)
{
if (sBCC.Length > 0)
{
for (int i = 1; i <= sBCC.Length; i++)
{
objMessage.Bcc.Add(sBCC[i - 1]);
}
}
}
// Body can be html or text format
if (IsHTML)
objMessage.IsBodyHtml = true;
objMessage.Subject = sSubject;
objMessage.Body = sMailBody;
// Send SMTP mail
objSMTPClient.Send(objMessage);
}
catch
{
}
}
My blog: http://www.asaf.co.il
|
|
|
|
|
You took all the fun out of having him do the research and actually LEARN something.
only two letters away from being an asset
|
|
|
|
|
He can learn a lot from the code snippest...
(At least I hope )
|
|
|
|
|
He'll learn to copy and paste
only two letters away from being an asset
|
|
|
|
|
yep that is correct he should have tried it first and then in case of problem should have asked here.
Best Regards,
Apurva Kaushal
|
|
|
|
|
|
Hello,
would anyone tell me how to set PayPal BuyNow button control's notify_url ? I want to use different IPN notify url for different products.
Regards
Emran
|
|
|
|
|
hi, can anyone help me on this problem thats occurring. I created a forum and its like this .. www.ivanandsimone.com/Query/Home.aspx. Now the problem is this, when i enter in the home.aspx 3 imagebuttons of 3 different items are shown above the page for instance (mobile, computer and book). When someone click on a picture it will take him in its (item description) of that item.
at that point everything works well but when a person clicks the back button of the windows explorer from the taskbar .. the pictures will ramins the same (mobile, computer and book) but the sessions will be overwrited by other numbers.
I am using Sessions to store every picture (the 3 pictures) ID number and then send that ID number to the Item.aspx page. The Item.aspx page will then see the ID and from the database it will search for the information about that ID that the user chosen.
Now the code is this:
This is for the Page_Load
If Request.QueryString("ItemID") <> "" Then<br />
Session(ID) = Request.QueryString("ItemID")<br />
<br />
Response.Redirect("Item.aspx")<br />
End If<br />
<br />
If Not IsPostBack Then<br />
Try<br />
odcConn = New OleDbConnection(strConn)<br />
daMem = New OleDbDataAdapter("Select * From tblItems Order By ItemID Desc", odcConn)<br />
dsMem.Clear()<br />
daMem.Fill(dsMem, "tblItems")<br />
dgItems.SelectedIndex = -1<br />
dgItems.DataSource = dsMem.Tables("tblItems")<br />
dgItems.DataBind()<br />
odcConn.Close()<br />
Session("Num1") = Nothing<br />
Session("Num2") = Nothing<br />
Session("Num3") = Nothing<br />
FillCategories()<br />
Catch ex As Exception<br />
odcConn.Close()<br />
End Try<br />
End If<br />
<br />
ChooseItems()<br />
End Sub
So the sessions - Session("Num1") and the other 2 are the storeage that i told you. Now for the Image Picker of the ImageButtons I am using this code:
Private Sub ChooseItems()<br />
Dim strImage As String<br />
Dim strItem As String<br />
Dim daItem As OleDbDataAdapter<br />
Dim ds As New DataSet<br />
Dim i As Integer = 0<br />
<br />
Dim randNum As New Random<br />
Dim intNum As Integer = randNum.Next(0, 22)<br />
<br />
odcConn = New OleDbConnection(strConn)<br />
daItem = New OleDbDataAdapter("SELECT * FROM tblItems", odcConn)<br />
daItem.Fill(ds, "tblItems")<br />
<br />
Try<br />
strImage = ds.Tables("tblItems").Rows(intNum)("Image1")<br />
<br />
imgItem1.ImageUrl = strImage<br />
<br />
strItem = ds.Tables("tblItems").Rows(intNum)("Item")<br />
<br />
lblItem1.Text = "Item: " & strItem<br />
<br />
If Session("Num1") = Nothing Then<br />
Session("Num1") = ds.Tables("tblItems").Rows(intNum)("ItemID")<br />
End If<br />
Catch ex As Exception<br />
odcConn.Close()<br />
Exit Try<br />
End Try<br />
<br />
intNum = randNum.Next(0, 22)<br />
daItem = New OleDbDataAdapter("SELECT * FROM tblItems", odcConn)<br />
daItem.Fill(ds, "tblItems")<br />
<br />
Try<br />
strImage = ds.Tables("tblItems").Rows(intNum)("Image1")<br />
<br />
imgItem2.ImageUrl = strImage<br />
<br />
<br />
strItem = ds.Tables("tblItems").Rows(intNum)("Item")<br />
<br />
lblItem2.Text = "Item: " & strItem<br />
<br />
If Session("Num2") = Nothing Then<br />
Session("Num2") = ds.Tables("tblItems").Rows(intNum)("ItemID")<br />
End If<br />
Catch ex As Exception<br />
odcConn.Close()<br />
Exit Try<br />
End Try<br />
<br />
intNum = randNum.Next(0, 22)<br />
daItem = New OleDbDataAdapter("SELECT * FROM tblItems", odcConn)<br />
daItem.Fill(ds, "tblItems")<br />
<br />
Try<br />
strImage = ds.Tables("tblItems").Rows(intNum)("Image1")<br />
<br />
imgItem3.ImageUrl = strImage<br />
<br />
strItem = ds.Tables("tblItems").Rows(intNum)("Item")<br />
<br />
lblItem3.Text = "Item: " & strItem<br />
<br />
If Session("Num3") = Nothing Then<br />
Session("Num3") = ds.Tables("tblItems").Rows(intNum)("ItemID")<br />
End If<br />
Catch ex As Exception<br />
odcConn.Close()<br />
Exit Try<br />
End Try<br />
<br />
odcConn.Close()<br />
End Sub
Can anyone help me in this problem because I got a big headache trying to fix this problem all night!
Adrian De Battista: .Net Programmer, Java Programmer and Web Designer.
|
|
|
|
|
that is a frequent problem with the back button, every time that the user press this button the page do nothing (postback or not postback), the solution is hide the address bar and forces the users to navigate back using a server hiperlink control from the page.
On the all htmls page write these head lines
...
These lines forces the explorer to reload all the images from the server
i Hope will be usefull for you
keep Learning and you never will be out of date...
|
|
|
|
|
I am VERY new to web development and have what is probably a simple question regarding SSL. (I have a lot of experience in VB, but not in web apps).
I have an SSL certificate installed on my windows 2003 server. What kind of code do I need to incorporate into my application to utilize the SSL? Is code necessary, or does IIS handle all that? Is there any code available?
I'm sure this stuff is second nature to you guys, but you gotta learn somewhere!
|
|
|
|