Siobhan Power Siobhan Power - 1 year ago 150
C# Question

inheritance c# (youtube api)

New to c# and .net
I want to create declare properties in the Video_details class, I then want to populate them with data from the video_page class and then pass them onto the Video_upload class where the data is used, could someone recommend ow I would this, normally use java
( I amm creating a website where you upload videos to youtube using youtube data api)


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
/// Summary description for Video_details
/// </summary>
public class Video_details
public Video_details()
// TODO: Add constructor logic here

public string vidTitle { get; set; }
public string vidDesc { get; set; }
public string vidTags { get; set; }


Video_page method code:

protected void btnUpload_Click(object sender, EventArgs e)
Video_details vidDetails = new Video_details();

//get details from textBoxes
txtTitle.Text = vidDetails.vidTitle.ToString();
txtDesc.Text = vidDetails.vidDesc.ToString();
txtTags.Text = vidDetails.vidTags.ToString();

//lblUploadStatus.Text = "Upload Starting";
Video_Upload uploadVideo = new Video_Upload();
new Video_Upload().Run().Wait();
// lblVidTitle.Text = "Upload Successful...fat chance thats true";


Video_Upload method code:


var video = new Video();
video.Snippet = new VideoSnippet();
video.Snippet.Title = Video_details.vidTitle.ToString();
video.Snippet.Description = "Testing Video Upload";
video.Snippet.Tags = new string[] { "Test", "Second" };
video.Snippet.CategoryId = "17";//category id for sport
video.Snippet.ChannelId = "UCfvR-wqeoHmAGrHnoQRfs9w";
video.Status = new VideoStatus();
video.Status.PrivacyStatus = "public"; // or "private" or "public"
var filePath = @"C:\Users\siobhan\Documents\Visual Studio 2015\WebSites\FYP_November\IMG_6638.mp4"; // Replace with path to actual movie file.

Answer Source

You seem to do the things the wrong way round. In View_page you must fill the properties of the Video_details from the text boxes:

vidDetails.vidTitle = txtTitle.Text;

Then the Video_Upload class must have some Upload method accepting a parameter of type Video_details

public class Video_upload
    public void Upload(Video_details video)
        //TODO: upload the data here

With this class you can then upload like this


For asynchronous uploads, have a look at Asynchronous Programming with async and await (C#) on MSDN.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download