
Commodus2
Members-
Posts
15 -
Joined
-
Last visited
Commodus2's Achievements
Newbie (1/14)
0
Reputation
-
The script is placed at the same level when the page is rendering. So it is seen as text and not executed. The thing I did, was to put in a js function in the SelectionChanged and then call it onClick of the button // This is the ok button. put it in the form and this code in the event function btnOk.Attributes.Add("onClick","doIt()"); hope this solves anything
-
DataList you say... Mayby that's the solution. I'll look into them right away. Thanks
-
Mayby i'm looking all wrong here. Is there mayby a better way to do this? All i want is a collection of buttons on a row Corresponding with a datarecord. Say I have 10 records all must have 'alter' and 'delete' buttons before them. If I click one of them it must do the action of the record(call the object that can perfor the operation) which it's assigned to by means of an id
-
There is no direct problem i guess... the only thing is that I cannot figure out why this event is not always triggered. Is it overwritten? shut down before it is supposed to fire? simply deleted from the to-be-executed queue? i don't know... and it frustrates me.... well... thanks for your help so far and I hope you can help me in the future. My .net knowledge isn't that strong also unfortunately thanks
-
First of all... thanks for the effort you are taking to look into my code :) I have debugged the code. It goes like this: It runs through Page_Load. all goed well. ShowHolliday. buttons are displayed. I press the 'approve' button(btnApprove in my code). It runs through the Page_Load again(obvious). ShowHolliday again. Buttons are displayed. And that's it! code stops. I press the approve button again. Page_Load, ShowHolliday, and yes requestManMutaion is called! mutation on the data is performed. The screen always runs behind on the mutation, this is because it is already printed when i mutate the data. When i call the ShowHolliday after the mutation it should work, is it not that the requestManMutatyion is not called the first time, os screen is empty and that is where my problem lies... no matter what i do, it always goes wrong. screen not up to date or code not called. greets Commodus
-
Sorry for the large code...
-
private bool ValidateLogin() { Response.Write("ValidateLogin()<br>"); bool returnValue = false; if (((CUser)Session["user"]) != null) { returnValue = true; } return returnValue; } // ------------------------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------------------------ private bool fillDdlEmployee() { Response.Write("fillDdlEmployee()<br>"); DataTable dt; //DataTable CDataRet dataRet = new CDataRet(); if (Session["user"] != null && ((CUser)Session["user"]).Employeeid > -1){ dt = dataRet.getData((CUser)Session["user"],"employees"); if (dt != null) { ddlEmployee.DataSource = dt; ddlEmployee.DataValueField = "id"; ddlEmployee.DataTextField = "Name"; if (!Page.IsPostBack){ ddlEmployee.DataBind(); } return true; } else { return false; } } else { return false; } } // ------------------------------------------------------------------------------------------------------------------ #region Web Form Designer generated code override protected void OnInit(EventArgs e) { Response.Write("OnInit()"); // // CODEGEN: This call is required by the ASP.NET Web Form Designer. // InitializeComponent(); base.OnInit(e); } /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> //this.ddlEmployee.SelectedIndexChanged += new System.EventHandler(this.ddlEmployee_SelectedIndexChanged); //this.btnLogout.Click += new System.EventHandler(this.btnLogout_Click); //this.Load += new System.EventHandler(this.Page_Load); private void InitializeComponent() { this.ddlEmployee.SelectedIndexChanged += new System.EventHandler(this.ddlEmployee_SelectedIndexChanged); this.btnLogout.Click += new System.EventHandler(this.btnLogout_Click); this.btnPersonalOverview.ServerClick += new System.EventHandler(this.btnPersonalOverview_ServerClick); this.Load += new System.EventHandler(this.Page_Load); } #endregion // ------------------------------------------------------------------------------------------------------------------ private void btnRequestHolliday_ServerClick(object sender, System.EventArgs e) { } // ------------------------------------------------------------------------------------------------------------------ private DropDownList cloneDropDownList(DropDownList ddl) { Response.Write("cloneDropDownList()<br>"); DropDownList retDdl = new DropDownList(); IEnumerator i = ddl.Items.GetEnumerator(); while (i.MoveNext()) { if (i.Current != null) { retDdl.Items.Add((ListItem)i.Current); } } return retDdl; } // ------------------------------------------------------------------------------------------------------------------ private void requestManMutation(Object sender, CommandEventArgs e) { // -------------------------------------------------------------------------- // ----------------- Function for commandevent handling --------------------- // -------------------------------------------------------------------------- CDataRet dataRet = new CDataRet(); Response.Write("requestManMutation()<br>"); if ((e.CommandName).Equals("delete")) { dataRet.deleteRow(Convert.ToInt32(e.CommandArgument)); } if ((e.CommandName).Equals("purge")) { dataRet.purgeRow(Convert.ToInt32(e.CommandArgument)); } if ((e.CommandName).Equals("approve")) { dataRet.approveRow(Convert.ToInt32(e.CommandArgument)); } Response.Write("<br><br><br>___________________"+e.CommandName + "_" + e.CommandArgument +"<BR>"); // -------------------------------------------------------------------------- // --- If i enable this, Event is not responding to buttons ----------------- // -------------------------------------------------------------------------- /*if (Session["user"] != null){ if (ddlEmployee.SelectedItem != null && ((CUser)Session["user"]).Employeeid != Convert.ToInt32(ddlEmployee.SelectedItem.Value)) ShowHolliday(Convert.ToInt32(ddlEmployee.SelectedItem.Value)); else ShowHolliday(((CUser)Session["user"]).Employeeid); }*/ } // ------------------------------------------------------------------------------------------------------------------ private void btnPersonalOverview_ServerClick(object sender, System.EventArgs e) { Response.Write("btnPersonalOverview_ServerClick()<br>"); if (Session["user"] != null) { if (ddlEmployee.Items.FindByValue(Convert.ToString(((CUser)Session["user"]).Employeeid)) != null) { ddlEmployee.SelectedIndex = ddlEmployee.Items.IndexOf(ddlEmployee.Items.FindByValue(Convert.ToString(((CUser)Session["user"]).Employeeid))); ShowHolliday(((CUser)Session["user"]).Employeeid); } } } private void ddlEmployee_SelectedIndexChanged(object sender, System.EventArgs e) { /* if (Session["user"] != null){ if (ddlEmployee.SelectedItem != null && ((CUser)Session["user"]).Employeeid != Convert.ToInt32(ddlEmployee.SelectedItem.Value)) ShowHolliday(Convert.ToInt32(ddlEmployee.SelectedItem.Value)); else ShowHolliday(((CUser)Session["user"]).Employeeid); } */ } private void btnLogout_Click(object sender, System.EventArgs e) { Response.Write("btnLogout_Click()<br>"); Session.Remove("user"); Page.Server.Transfer("login.aspx"); } // ------------------------------------------------------------------------------------------------------------------ } } [edit]please use tags [/cs ] [/edit][/color]
-
Ok.. it is a whole bunch a code... beware :) the most important functions are Page_Load, ShowHolliday(i know missspelled) and requestManMutation. using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Data.SqlClient; using System.Drawing; using System.Text.RegularExpressions; using System.Web; using System.Web.SessionState; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; namespace HollidayReg { /// <summary> /// Summary description for WebForm2. /// </summary> public class main_man : System.Web.UI.Page { protected System.Web.UI.HtmlControls.HtmlInputButton btnRequestHolliday; protected System.Web.UI.WebControls.Table tblHollidayView; protected System.Web.UI.WebControls.DropDownList ddlEmployee; protected System.Web.UI.WebControls.Label Label1; protected System.Web.UI.WebControls.Button btnLogout; protected System.Web.UI.HtmlControls.HtmlInputButton btnPersonalOverview; // ------------------------------------------------------------------------------------------------------------------ private void Page_Load(object sender, System.EventArgs e) { Response.Write("Page_Load()<br>"); if (!ValidateLogin()) { Server.Transfer("login.aspx"); } else { Response.Write(sender.GetType().ToString()+"<BR>"+e+"<BR>"); // filling droplists with data from database if (!fillDdlEmployee()) { throw new Exception("Error fetching employees from database"); } if (Session["user"] != null) { int id = ((CUser)Session["user"]).Employeeid; //if (!Page.IsPostBack){ if (ddlEmployee.SelectedItem != null && id != Convert.ToInt32(ddlEmployee.SelectedItem.Value)) ShowHolliday(Convert.ToInt32(ddlEmployee.SelectedItem.Value)); else ShowHolliday(id); //} } } } // ------------------------------------------------------------------------------------------------------------------ private void ShowHolliday(int id) { Response.Write("ShowHoliday()<br>"); try{ CDataRet dataRet = new CDataRet(); ArrayList al = new ArrayList(); al = dataRet.getHollidays(id); tblHollidayView.Rows.Clear(); TableRow trHeader = new TableRow(); TableCell tdHeader = new TableCell(); // table header tdHeader.Text="<b>Actions</b>"; trHeader.Cells.Add(tdHeader); tdHeader = new TableCell(); tdHeader.Text="<b>Type</b>"; trHeader.Cells.Add(tdHeader); tdHeader = new TableCell(); tdHeader.Text="<b>Owner</b>"; trHeader.Cells.Add(tdHeader); tdHeader = new TableCell(); tdHeader.Text="<b>Starttime</b>"; trHeader.Cells.Add(tdHeader); tdHeader = new TableCell(); tdHeader.Text="<b>Endtime</b>"; trHeader.Cells.Add(tdHeader); tdHeader = new TableCell(); tdHeader.Text="<b>Approved</b>"; trHeader.Cells.Add(tdHeader); tdHeader = new TableCell(); tdHeader.Text="<b>Deleted</b>"; trHeader.Cells.Add(tdHeader); tdHeader.Dispose(); tblHollidayView.Rows.Add(trHeader); trHeader.Dispose(); IEnumerator e = al.GetEnumerator(); while (e.MoveNext()) { TableRow tr = new TableRow(); TableCell td = new TableCell(); Button btnAlter = new Button(); btnAlter.CssClass = "buttonAction"; btnAlter.CommandName = "alter"; btnAlter.CommandArgument = Convert.ToString(((CHolliday)e.Current).Id); btnAlter.Command+=new CommandEventHandler(requestManMutation); btnAlter.Attributes.Add("onClick","openRequestWindow('"+Convert.ToString(((CHolliday)e.Current).Id)+"')"); btnAlter.Text="Alter"; td.Controls.Add(btnAlter); // -------------------------------------------------------------------------- // ---------------------- Buttons created here ------------------------------ // -------------------------------------------------------------------------- if (((CUser)Session["user"]).Employeeid != id || ((CUser)Session["user"]).Managerid == id) { Button btnPurge = new Button(); btnPurge.CssClass = "buttonAction"; btnPurge.CommandName = "purge"; btnPurge.CommandArgument = Convert.ToString(((CHolliday)e.Current).Id); btnPurge.Command+=new CommandEventHandler(requestManMutation); btnPurge.Text = "Delete"; td.Controls.Add(btnPurge); Button btnApprove = new Button(); btnApprove.CssClass = "buttonAction"; btnApprove.CommandName = "approve"; btnApprove.CommandArgument = Convert.ToString(((CHolliday)e.Current).Id); btnApprove.Command+=new CommandEventHandler(requestManMutation); btnApprove.Text = "Approve"; td.Controls.Add(btnApprove); } else { Button btnDelete = new Button(); btnDelete.CssClass = "buttonAction"; btnDelete.CommandName = "delete"; btnDelete.CommandArgument = Convert.ToString(((CHolliday)e.Current).Id); btnDelete.Command+=new CommandEventHandler(requestManMutation); btnDelete.Text = "Delete"; td.Controls.Add(btnDelete); } // -------------------------------------------------------------------------- // -------------------------------------------------------------------------- // -------------------------------------------------------------------------- tr.Cells.Add(td); td = new TableCell(); td.Text = ((CHolliday)e.Current).TypeName; tr.Cells.Add(td); td = new TableCell(); td.Text = ((CHolliday)e.Current).OwnerName; tr.Cells.Add(td); td = new TableCell(); td.Text = ((DateTime)((CHolliday)e.Current).StartDate).ToString(); tr.Cells.Add(td); td = new TableCell(); td.Text = ((DateTime)((CHolliday)e.Current).EndDate).ToString(); tr.Cells.Add(td); td = new TableCell(); bool approved = ((CHolliday)e.Current).Approved; if (approved) { td.Text = "True"; } else { td.Text = "False"; } tr.Cells.Add(td); td = new TableCell(); bool deleted = ((CHolliday)e.Current).Deleted; if (deleted) { td.Text = "True"; } else { td.Text = "False"; } tr.Cells.Add(td); td.Dispose(); tblHollidayView.Rows.Add(tr); tr.Dispose(); } tblHollidayView.DataBind(); Session.Add("tblHollidayView",tblHollidayView); } catch(Exception ae) { Response.Write(ae.StackTrace.ToString()+" "+ae.Message.ToString()); } } [edit]please use tags [/cs ] [/edit][/color]
-
Hi, I have this problem when an event is triggered... better say.. not triggered. I have a WebControl.Table. filled with rows with buttons in them, created dynamicaly. all is fine. filled in page_load. If i press a button, a CommandEvent is triggered so that in this way i can check which button is pressed. it doesn't trigger it the first time. I press the button. page reloads(postback) because the table is filled in page_load, the data is shown, but the event is not triggered. If i then press the button again, it is triggered. page reloads and the story goes on. I have to press the button twice before the event is triggered. I placed reponse.writes in the funtion to see which functions are called. guess what... the commandevent function is not called the first time. Looks like it is cut off the first time. I am confused why it calls it the second time... When i trace the code. it just stops when it filled the table(in a postback) showing the data in the table on the screen. when i put an if around the filling code saying that it only fills the table when page is not poastback, it just not filles it... and the event is not triggered and i pushed the button. I hope someone can help me. It is very difficult to explain a problem here from scratch. Greetz Commodus2
-
So you say your function is in another aspx file than your aspx that needs the script? if you Register a script in 1 window to be activated in another, you'll run into trouble. It cannot be done. RegisterScript is happening at runtime, so it must be in the page that needs it clientside.
-
Mayby you can try RegisterStartupScript
-
How can i send an email using mapi? I cannot use smtp since my company will not support/enable it (don't ask me why) it is an Echange 2000 server. I am creating an web apllication that has to send an email as a notification. Not recieve. Thanks, Commodus2
-
Hi there, I have a problem with SelectBoxes. the drop down area is too small. Enlarging the whole object is not the solution. I want to keep the selectbox small and the dropdown area bigger. I work on a C#.NET app and I want die override the RenderControl method of DropDownList. In this way I hope that I manage to render the drop downarea with div's so that I can make this area larger then the box itself. How do I override this function? Can i override only this function and leave the rest intact? I never made an custom control before. Hope someone knows the answer. Thanks
-
Ok thanks! I was thinking of doing something like that... but didn't figure it out just yet. thanks for that! it works. although I'm still messing with the literal. I replaced this with a Page.RegisterStartupScript("start",strBlJscript.ToString()); it works also :) in this way you don't need a literal. at least.... i think i have this right thanks again for you advice!
-
Hi. I want to use a calendar in a popup window. showModalDialog with javascript does niot work because you cannot use links in a showModalDialog. i cannot manipulate the field that must contain a date from within the popup because i wat to use this popup several times on several different places. how can i do this? I have Visual Studio .net and i am fairly new to it. thanks