Category Archives: Upload

[RESOLVED] how to post a video on video player

I want to post few videos on a website but i don't want to use youtube or any other website.

I want to have an in-build player on the webpage with video in it - how to accoplish that ?

Object tag????

if you dont prefer that...you got to think of Silverlight...

Thanks.

How I can do this :http://www.asp.net/general/videos/how-do-i-multiple-file-uploads-in-aspnet-2

Could you please help me with the code and things needs to be done in order to accoplish this ?

Complete code....

<%@ Page Language="C#"%>
<%@ Import Namespace="System.IO" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
    protected void Page_Load(object sender, EventArgs e)
    {
        String UpPath;
        UpPath = "C:\\UploadedUserFiles";

        if (!Directory.Exists(UpPath))
        {
            Directory.CreateDirectory("C:\\UploadedUserFiles\\");
        }
    }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        HttpFileCollection uploads = HttpContext.Current.Request.Files;
        for (int i = 0; i < uploads.Count; i++)
        {
            HttpPostedFile upload = uploads[i];

            if (upload.ContentLength == 0)
                continue;

            string c = System.IO.Path.GetFileName(upload.FileName); // We don't need the path, just the name.

            try
            {
                upload.SaveAs("C:\\UploadedUserFiles\\" + c);
                Span1.InnerHtml = "Upload(s) Successful.";
            }
            catch (Exception Exp)
            {
                Span1.InnerHtml = "Upload(s) FAILED.";
            }
        }
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
</head>
<body>
<form id="form1" runat="server" enctype="multipart/form-data">
<p id="upload-area">
   <input id="File1" type="file" runat="server" size="60" />
</p>

<input id="AddFile" type="button" value="Add file" onclick="addFileUploadBox()" />
<p><asp:Button ID="btnSubmit" runat="server" Text="Upload Now" OnClick="btnSubmit_Click" /></p>
<span id="Span1" runat="server" />

<script type="text/javascript">
    function addFileUploadBox() {
        if (!document.getElementById || !document.createElement)
            return false;

        var uploadArea = document.getElementById("upload-area");

        if (!uploadArea)
            return;

        var newLine = document.createElement("br");
        uploadArea.appendChild(newLine);

        var newUploadBox = document.createElement("input");

        // Set up the new input for file uploads
        newUploadBox.type = "file";
        newUploadBox.size = "60";

        // The new box needs a name and an ID
        if (!addFileUploadBox.lastAssignedId)
            addFileUploadBox.lastAssignedId = 100;

        newUploadBox.setAttribute("id", "dynamic" + addFileUploadBox.lastAssignedId);
        newUploadBox.setAttribute("name", "dynamic:" + addFileUploadBox.lastAssignedId);
        uploadArea.appendChild(newUploadBox);
        addFileUploadBox.lastAssignedId++;
    }
</script>
</form>
</body>
</html>



[RESOLVED] embedding image not displaying in emaill using vb.net

Hi

I am trying to display an embed an image within the body of an email. The is sent, however without the image.

Below is the code:

Dim mail As New MailMessage()


mail.[To].Add("siu07aj@reading.ac.uk")


mail.From = New MailAddress("atiqisthebest@hotmail.com")


mail.Subject = "Test Email"




Dim Body As String = "<b>Welcome to codedigest.com!!</b><br><BR>Online resource for .net articles.<BR><img alt="""" hspace=0 src=""cid:imageId"" align=baseline border=0 >"


Dim htmlView As AlternateView = AlternateView.CreateAlternateViewFromString(Body, Nothing, "text/html")


Dim imagelink As New LinkedResource(Server.MapPath(".") & "\uploads\CIMG1443.JPG", "image/jpg")


imagelink.ContentId = "imageId"


imagelink.TransferEncoding = System.Net.Mime.TransferEncoding.Base64


htmlView.LinkedResources.Add(imagelink)


mail.AlternateViews.Add(htmlView)


Dim smtp As New SmtpClient()


smtp.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis
smtp.Host = ConfigurationManager.AppSettings("SMTP")
smtp.Port = 587
'smtp.EnableSsl = True


smtp.Credentials = New System.Net.NetworkCredential(ConfigurationManager.AppSettings("FROMEMAIL"), ConfigurationManager.AppSettings("FROMPWD"))


smtp.Send(mail)

In the body of the email only the following is display:

Welcome to CodeDigest.Com!!

Any idea how I can get the CIMG1443.JPG displaying?

Thanks

Hi,

is  Image is there on The path Which Your Specifiying?

Dim imagelink As New LinkedResource(Server.MapPath(".") & "\uploads\CIMG1443.JPG")


imagelink.ContentId ="test"

OR

U send Html Image Tag then define image in that

Example :- --message--<img src="http://www.server.com/1.jpg"/>

OR

http://msdn.microsoft.com/en-us/vbasic/bb630227

above link may be good Resource for you.

[RESOLVED] Import data from text and excel

Hello, I am working on a C# web application under visual studio 2005.

I want to import data from text file or excel file into a SQL 2005 database.
I have 3 columns in the text file separated by |, example of the text file format:

1|11122222|Name1
2|22299809|Name2

Can you tell me how to import data from text or excel file?

Another question, if you provide a solution for the import from excel, can you note which office (2003 or 2007 or 2010)?

Thank you.

lebdeveloper

Another question, if you provide a solution for the import from excel, can you note which office (2003 or 2007 or 2010)?
 

Check this solution..

http://weblogs.asp.net/rajbk/archive/2009/05/02/uploading-an-excel-file-to-sql-through-an-asp-net-webform.aspx

lebdeveloper

I have 3 columns in the text file separated by |, example of the text file format:

Break each line into string array with char separator "|". After that you can use above code to upload.

Hi, firt of all, you need to know the path of the file. I recommend you use cvs files for working with excel.

Any Excel can open this kind of file. Then You should do something like this:

StreamReader sw = new StreamReader("path of file + file + .extension");


while(!sw.EndofStream)
{
string[] partsOfString = sw.ReadLine().split('|');


set a parameter = partsOfString[0];
set a parameter = partsOfString[1];
set a parameter = partsOfString[2];


command.parameters.add(params);
command.ExecuteInsert();
}


All this doing normal process to insert into a database right?


lebdeveloper

Can you tell me how to import data from text or excel file?

You can use OLeDB connection for reading a Xls file...and you can use StreamReader to read the txt file....

When you read xls file, you can fill the dataset using that data and then call a stored proc in Sql DB to make bulk insert....the easient way to do is, convert the dataset to Xml, and give that xml as input to the stored proc...and in the stored proc you can easily parse the xml and make inserts into the DB....

For txt file, you got to parse the string which you get out of streamreader, and then write some code to convert it into DataTable which will be merged to a dataset, then follow the above procedure....

PS - I have given you conceptual idea on how it works...you got read with some articles on line on how to accomplish the above said tasks...may be you can break them into smaller tasks and go one at a time...

Thanks.

[RESOLVED] <button disable="disable" does not work if I want to disable behind

I have the following: I would like to disable protected void btnSend_Click(object sender, EventArgs e) { if (Page.IsValid) { btnSend.Disabled = true; System.Threading.Thread.Sleep(2000); } this does not wor

I have the following:
<button id="btnSend" runat="server" alt="" CausesValidation="false" önserverclick="btnSend_Click">
<img id="imgSend" alt="" runat="server" src="~/Images/Buttons/send_ico.gif"
align="top" />


 Send Message</button>


I would like to disable


protected void btnSend_Click(object sender, EventArgs e)
{


if (Page.IsValid)
{
btnSend.Disabled = true;
System.Threading.Thread.Sleep(2000);
}
this does not work.


k.

Can you explain what you are tyring to do? Disabling button when page is valid to stop duplicate postbacks. If so, you can do this...

Markup:

<%@ Page Language="C#" AutoEventWireup="true" EnableEventValidation="false" CodeBehind="WebForm5.aspx.cs"
    Inherits="WebApplication1.WebForm5" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <asp:TextBox ID="txt" runat="server"></asp:TextBox>
    <asp:RequiredFieldValidator ErrorMessage="Required" ControlToValidate="txt" ForeColor="Red"
        Display="Dynamic" SetFocusOnError="true" runat="server" />
    <asp:Button ID="buttonSave" runat="server" CausesValidation="true" Text="Do Something"
        OnClick="buttonSave_Click" />
    </form>
</body>
</html>

CodeBehind:

protected void Page_Load(object sender, EventArgs e)
{
    buttonSave.Attributes.Add("onclick""Page_ClientValidate();if(Page_IsValid){this.disabled=true;" +
                                Page.ClientScript.GetPostBackEventReference(buttonSave, "Test") + ";}");

}
protected void buttonSave_Click(object sender, EventArgs e)
{
    Thread.Sleep(2000);
}

Try that way and see if it works. Button will be disabled when page is valid.

sometimes the user can click the button twice.

I want to disable this.

 

buttonSave.Attributes.Add("onclick""Page_ClientValidate();if(Page_IsValid){this.disabled=true;" +
                                Page.ClientScript.GetPostBackEventReference(buttonSave, "Test") + ";}");

this is only good for the asp.net button asp:button tag.

 

<button id="btnSend" runat="server" alt="" CausesValidation="true" onserverclick="btnSend_Click">
                        <img id="imgSend" alt="" runat="server" src="~/Images/Buttons/send_ico.gif"
                            align="top" />
                        <span> <b class="va">Send Message</b></span></button>


this is a html button.

it does not work like a asp:button.

Hi,

Accroding to your code, it seems that the button will be disabled after 2 seconds. Is it what you want to implement?

If I'm not misundertood you, you can try to comment the code "System.Threading.Thread.Sleep(2000)".

Or use the client side javascript:

btnSend.Attributes["onclick"] = "this.disabled = true;";

Here System.Threading.Thread.Sleep(2000) is used to do a delay time manually in order to let us see how this disable property affect the button before the button sumbit.

Above poster give you a good example, whatever the button is asp:button or HtmlButton. It should always work.

I modify it for HtmlButton:

protected void Page_Load(object sender, EventArgs e)
        {
           btnSend.Attributes["onclick"] = "this.disabled = true;";
         }






        protected void btnSend_Click(object sender, EventArgs e)
        {
            System.Threading.Thread.Sleep(2000);
        }


 <asp:ScriptManager ID="ScriptManager1" runat="server">
            </asp:ScriptManager>
            <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                <ContentTemplate>
                    <button id="btnSend" runat="server" alt="send" causesvalidation="false"  onserverclick="btnSend_Click">
                        <img id="img1" alt="" runat="server" src="~/Images/20100920105445544.jpg" align="top" />
                        Send Message</button>
                </ContentTemplate>
            </asp:UpdatePanel>


The button will disabled 2 seconds.

Hope this can help you.

[RESOLVED] Integrate google search in my webpage

Hi I want to integrate googl search in my webpage how can i do that?

Actually i placed code likt this

 

<

form action="http://www.duckyvideos.com" id="cse-search-box">

 

<div>

 

<input type="hidden" name="cx" value="partner-pub-9481442241155955:7j2htu-qsi5" />

 

<input type="hidden" name="cof" value="FORID:10" />

 

<input type="hidden" name="ie" value="ISO-8859-1" />

 

<input type="text" name="q" size="31" />

 

<input type="submit" name="sa" value="Search" />

 

</

<

 

<

<

</div>form>script type="text/javascript" src="http://www.google.com/coop/cse/brand?form=cse-search-box&amp;lang=en"></script>div id="cse-search-results"></div>script type="text/javascript">

 

 

 

 

 

var googleSearchIframeName = "cse-search-results";var googleSearchFormName = "cse-search-box";var googleSearchFrameWidth = 800;var googleSearchDomain = "www.google.com";var googleSearchPath = "/cse";

</

<

 

script>script type="text/javascript" src="http://www.google.com/afsonline/show_afs_search.js"></script>

 

 

but it is not working for me. what is the problem

 

 

Thanks in advance

 

Hi ,

Check  this   http://forums.asp.net/p/1289399/2487448.aspx#2487448


Hope  this  helps..


hi,

Read their instructions:

http://www.google.com/services/search.html#utm_medium=et&utm_source=bizsols&utm_campaign=web_site_search

and also check this article,

http://www.c-sharpcorner.com/UploadFile/mchandramouli/IntegratingGoogleSearch11242005033911AM/IntegratingGoogleSearch.aspx

Hi,

 

I used your code. but problem is that when I use one of my site www.logicalsofttech.com it works perfect

 

but When I used (www.cliffords-estate.co.uk) or (cliffords-estate.co.uk)  it does't work

 

Please help me to soulve the issue

 

Thanks