Jump to content

jaylisto

Members
  • Posts

    12
  • Joined

  • Last visited

Posts posted by jaylisto

  1. i plan to make a fill up data sheet in the web form with c# instead of infopath.

     

    id tried the report manager witch i found out in youtube tutorial and it just print all the data in my data base like an excel type.

     

    i wonder i can choose data to be print with template.

     

    example.

     

    i want to print data like it was typed in a Microsoft word but selected data was came from the data base.

     

     

     

    this product is sold to (data from database) from (data from database ) date: (from database)

     

     

    and donwload / print it like it was typed in the microsoft word.

     

     

    if a video tutorial similar on my case. pleas share it. im new in asp.net. so i dont know how can i describe this one and search it in youtube.

  2. this is a very simple task, it insert name, address and age to the database

     

    error when the sql data base from server is use.

     

    but when data base from folder app_data is used its working.

     

     

     

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Data.SqlClient;
    using System.Configuration;
    namespace WebApplication5
    {
    public partial class WebForm1 : System.Web.UI.Page
    {
    SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
    protected void Page_Load(object sender, EventArgs e)
    {
    con.Open();
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
    SqlCommand cmd = new SqlCommand("insert into listotable values('"+TextBox1.Text+"','" +TextBox2.Text+"', '"+TextBox3.Text+"')",con);
    cmd.ExecuteNonQuery();
    con.Close();
    TextBox3.Text="";
    TextBox2.Text="";
    TextBox1.Text="";
    }
    }
    }
    Untitled1_zps60a36e80.jpg
  3. here's what i did on viewstate.....

     

    int j=0,k =12; protected void Page_Load(object sender, EventArgs e) { imagesthumbnailjaylisto(); if (!IsPostBack) { ViewState["clicks"] = j; //when the page loads the value of j is 0 by default and the value of k is 12 as declared on the top. ViewState["clicks2"] = k; } } protected void Button1_Click(object sender, EventArgs e) { if (ViewState["clicks"] != null && ViewState["clicks2"] != null) { j = (int)ViewState["clicks"] + 12; //this part really adds a value of 12 to each variable j and k k = (int)ViewState["clicks2"] + 12; } ViewState["clicks"] = j; ViewState["clicks2"] = k;

    Response.Write(j); //this part is the proof that every time i pressed the next button it really keeps on adding value from viewstate["clicks"].

    Response.Write(k);

    }

     

     

    on the part of your loop which is

     

    for (i=j; ((i<pixpaths.Count)&&(i<k)) ; i++) // but the value of j and k keeps on default which is 0 and 12

  4. yes it does work. thank you for your help.but when i implement it in the next button in my gallery issues keeps on coming.

     

    i guest html destroys every variable i made every time i pressed "next button" that what makes it harder.

     

    in the static variable, the next button needs to press twice before the next set of thumbnails.

     

    i tried season state, static and viewstate

     

    i feel so dumb right now :(

  5. dude! i cant solve it. this portion will solve my problem on the link next button of my gallery. i dont know if i will start a new topic for this one.

     

    can you please help me every time i press the button it should count the number of clicked.

    i tried using static variable, yes it worked.

    but every time i re run the code the static will continue to its last value.

     

     

    public partial class WebForm1 : System.Web.UI.Page { static int count = 0; protected void Button1_Click(object sender, EventArgs e) { count += 1; Response.Write(count); } protected void Page_Load(object sender, EventArgs e) { } }

     

     

    I tried putting count = 0; in the page load but it didnt work. it keeps the count into zero.

    i think web form reruns the page load every time changes are done to the form.

     

    how can i solve this scenario. :facepalm:

  6. Ok, so rather than using the for-each to load everything, why not use the for-each to merely create an array of strings?

    List<string> pixpaths = new List<string>(); // make this static/global/sessionint pixcounter = 0; // make this static/global/sessionint i = 0;foreach (string strFileName in Directory.GetFiles(Server.MapPath("~/pictures/loveones/")))  {  pixpaths.Add(strFileName);  i++;}if (pixpaths.Count>10){  pixcounter += 10;}else{  pixcounter = 0;}for (i=0 ; ((i<pixpaths.Count)&&(i<10)) ; i++){ImageButton imageButton = new ImageButton();FileInfo fileInfo = new FileInfo(pixpaths[i]);imageButton.ImageUrl = "~/pictures/loveones/" + fileInfo.Name;imageButton.Width = Unit.Pixel(200);imageButton.Height = Unit.Pixel(200);imageButton.Style.Add("padding", "5px");imageButton.Click += new ImageClickEventHandler(imageButton2_Click);Panel1.Controls.Add(imageButton);} }void imageButton_Click(object sender, ImageClickEventArgs e) { Response.Redirect(((ImageButton)sender).ImageUrl);}} 

    Then your next-button event routine would advance the photo display with a similar for-next loop. The global/static/session pixcounter would keep track of where you are in the array. I don't really remember how you create a global/static/session variable in ASP.NET but you can look that up.

     

    i will definetly search for that global/static/session. by the way.

     

    wow! you are amazing sir. i really upriciate your code. it really works. limitting 10 photos on the gallerynow the button "next" without redirecting the page will be my next problem.after pressing the button next , im planning to add numbers in the for loop portion like this one.

    for (i=10 ; ((i<pixpaths.Count)&&(i<20)) ; i++)

     

    is this possible?

     

    i will post my code later after numerous attempt. thank you very much.

  7. ok ill just put all the codes here.

    using System;using System.Collections.Generic;using System.Linq; using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using System.IO;namespace WebApplication5{public partial class WebForm1 : System.Web.UI.Page{protected void Page_Load(object sender, EventArgs e){jayvalue();}}Response.Redirect("~/WebForm1.aspx");}private void jayvalue(){foreach (string strFileName in Directory.GetFiles(Server.MapPath("~/pictures/loveones/")))                  // "this portion is the loop where it loads all the content of all images in the folder pictures/loveones/"{ImageButton imageButton = new ImageButton();FileInfo fileInfo = new FileInfo(strFileName);imageButton.ImageUrl = "~/pictures/loveones/" + fileInfo.Name;imageButton.Width = Unit.Pixel(200);imageButton.Height = Unit.Pixel(200);imageButton.Style.Add("padding", "5px");imageButton.Click += new ImageClickEventHandler(imageButton2_Click);Panel1.Controls.Add(imageButton);} }void imageButton_Click(object sender, ImageClickEventArgs e) { Response.Redirect(((ImageButton)sender).ImageUrl);}} }
  8. been searching for the answer for a long time

     

    i have this working code for a simple photo gallery for viewing photos

    when the images are too many it will take a long time to load all the imagebuttons

     

    i want to limit the imagebutton's to load only 10 photos, i will just put another next button for the next 10 photos and so on.

     

     

    this foreach loop portion is where it loads all the pictures inside the folder named "loveones"

    ImageButton imageButton = new ImageButton();FileInfo fileInfo = new FileInfo(strFileName);imageButton.ImageUrl = "~/pictures/loveones/" + fileInfo.Name;imageButton.Width = Unit.Pixel(200);imageButton.Height = Unit.Pixel(200);imageButton.Style.Add("padding", "5px");imageButton.Click += new ImageClickEventHandler(imageButton2_Click);Panel1.Controls.Add(imageButton);

    i wish some one could help me here in w3 school. thanks.

     

×
×
  • Create New...