I would like to Click "buttonImage1" and have that store "photos/Image1.jpg"
into a var called Photo. then have ButtonImage2.ImageUrl = (Photo).
I am using an UpdatePanel to refresh the area with the images so the only problem is actually setting the variable correctly and then using it correctly.
Reworded: how can I store a path to an image in a variable then set it correctly as a image's URL path?
protected void Button2_Click(object sender, ImageClickEventArgs e)
{
Evt = ("~/events/ev2.jpg");
}
protected void Image2_Click(object sender, ImageClickEventArgs e)
{
Image1.ImageUrl = (Evt);
}
use Server.MapPath to set image path
Image1.ImageUrl = Server.MapPath(Evt);
Related
I have this webform:
public class web1{
private string target = string.Empty;
protected void Page_Load(object sender, EventsArgs e){
target = "something";
}
protected void btnSubmit_Click(object sender, EventArgs e){
//use target variable here
}
}
When I click the button which triggers btnSubmit_Click() the target variable gets reset to string.Empty because of private string target = string.Empty.
Currently I'm assigning the new value to a Session and clearing it after the button click, but was wondering if there was a way of avoiding Session.
This typcial would work:
private string target = string.Empty;
protected void Page_Load(object sender, EventsArgs e){
if (!IsPostBack)
{
target = "something";
ViewState["target"] = target;
}
else
target = (string)ViewState["target"];
}
Now any button click, event code, or whatever is free to use target.
I have an application that displays various data in an ASP.NET GridView. The values are displayed as a selection of combobox. When I select comobo box, the reload process is taking about 8 seconds. I would like to display a gif of load before starting the process and end it cancel the display image. I tried to use a thread for this, but it did not work very well. Could someone help me?
protected void Page_Load(object sender, EventArgs e)
{
//My Image
imageLoad.Visible = true;
Assembly myAsm = Assembly.Load("PainelBordo");
AssemblyName aName = myAsm.GetName();
Version version = aName.Version;
BusinessLogicLayer bll = new BusinessLogicLayer();
LoadDDLWRTG(CreateDataTableWRTGList());
LoadDataPBList();
TimerRefresh.Interval = Convert.ToInt32(ConfigurationManager.AppSettings["TimerInterval"].ToString());
lblUpdateDate.Text = "Refresh " + bll.DateUpdateFormat(DateTime.Now);
// My image
imageLoad.Visible = false;
}
Combobox SelectedIndexChanged.
protected void ddlWRTGroup_SelectedIndexChanged(object sender, EventArgs e)
{
Page_Load(sender, e);
}
Drag and drop a Button(btnInvoke) and Label(lblText) control inside the UpdatePanel. Also add a <div id="divImage"> inside the UpdatePanel. This div will contain a .gif image that depicts progress and is initially set to invisible style="display:none". On the button click, perform a time consuming task. In our case, we have set a delay of 3 seconds by using Thread.Sleep(3000)
C#
protected void btnInvoke_Click(object sender, EventArgs e)
{
System.Threading.Thread.Sleep(3000);
lblText.Text = "Processing completed";
}
Took from here
My Crystal Report works fine in the first page but when i click on the next page button the report doesn't load and gives Missing parameter values error. Can anybody help me to solve this problem.
My current coding is given below.
protected void ddlStudent_SelectedIndexChanged(object sender, EventArgs e)
{
GenerateReport();
}
protected void GenerateReport()
{
//Create report document
ReportDocument crystalReport = new ReportDocument();
//Load crystal report made in design view
crystalReport.Load(Server.MapPath("Reports/PhotoGallery.rpt"));
//Set DataBase Login Info
crystalReport.SetDatabaseLogon("root", "pwd", #"localhost", "nsis");
//Provide parameter values
crystalReport.SetParameterValue("adno", adNo);
crvReportViewer.ReportSource = crystalReport;
}
I think you need to call GenerateReport(); method in page load as well try following
protected void ddlStudent_SelectedIndexChanged(object sender, EventArgs e)
{
GenerateReport();
ViewState["ReportLoad"] = "Load";
}
protected void Page_Load(object sender, EventArgs e)
{
if (ViewState["ReportLoad"] != null)
{
GenerateReport();
}
}
Because of the environment I work in I need to add controls to a page via code-behind. I have done it dozens of times. For some reason the FileUpload control is giving me grief. here is my code:
FileUpload fileUpload = new FileUpload();
fileUpload.ID = "FileUploadControl";
this.Controls.Add(fileUpload);
The page looks as though it is timing out and display this error, "Internet Explorer cannot display the webpage".
When I remove the last line (the Add), then the page renders just fine.
Any ideas?
Thanks!!
You didn't mentioned which event handler you have used. Please try this,
FileUpload file;
protected void Page_Load(object sender, EventArgs e)
{
file= new FileUpload();
PlaceHolder1.Controls.Add(file);
}
protected void Button1_Click(object sender, EventArgs e)
{
if(file.HasFile)
{
file.SaveAs(MapPath("~/" + file.FileName));
}
}
i want to creat a web page that uses radiobuttons in a multiple choice quetions, but i want to do is to use a submit button to return the results to the next page with the mark sheet, so can you please help me with that. how to display the mark sheet on the next page using ASP.NET
Use Session state.
For example,
protected void Button1_Click(object sender, EventArgs e)
{
Session["key"] = TextBox1.Text;
Response.Redirect("marksheet.aspx");
}
Code in Page_Load of marksheet.aspx,
protected void Page_Load(object sender, EventArgs e)
{
if (Session["key"] != null)
{
object val = Session["key"];
...
}
}