SEARCH YOUR SOLUTION HERE  

Which Control caused PostBack?

I have a dropdown list and button that cause postback, each with events that are getting fired correctly after Page_Load. How can I determine which control caused the postback in OnInit()

Posted On: Tuesday 27th of November 2012 11:02:08 PM Total Views:  164
View Complete with Replies




Related Messages:

Problem setting attributes for my webpart which inherits webpart   (149 Views)
Hi all, I am having trouble getting my attributes set in my class. Especially with the font color, back color etc. Please check my code below and let me know if I am missing assembly references, or just need to correct syntax for the values to be acceptable. Code:using System;using System.Data;using System.Configuration;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Drawing;namespace PETS_Webpart_Mgmt{ class Pets_Webpart : WebPart { // Constructor public Pets_Webpart() { this.owClose = true; this.owMinimize = false; this.Title = "Pet 1"; this._role = string.Empty; this._department = string.Empty; } // Fields - Private private String _role = string.Empty; private String _department = string.Empty; private DataSourceControl _dataSource; //Properties public string Role { get { return _role; } set { _role = value; } } public override bool owMinimize { get { return false; } set { ;} } #region Methods // Methods protected override void CreateChildControls() { //Retrieve the current values from the web part Pets_Webpart wp = new Pets_Webpart(); //wp = CType(ParentToolPane.SelectedWebPart, Pets_Webpart); // Build the body "body" control HtmlGenericControl body = new HtmlGenericControl(); body.Attributes.Add("class", "controlBody"); body.Attributes.Add("id", "ctrlBody"); // Build the "Update Panel" control System.Web.UI.UpdatePanel upPanel = new System.Web.UI.UpdatePanel(); upPanel.ID = "upPanel"; upPanel.UpdateMode = UpdatePanelUpdateMode.Conditional; // Build the "title panel" control System.Web.UI.WebControls.Panel pnlTitle = new System.Web.UI.WebControls.Panel(); pnlTitle.ID = "pnlTitle"; pnlTitle.BackColor = System.Web.UI.WebControls; pnlTitle.CssClass = "Parts"; pnlTitle.Height = 28; // Build the Title label control System.Web.UI.WebControls.Label lblTitle = new System.Web.UI.WebControls.Label(); lblTitle.ID = "lblTitle"; lblTitle.Text = Title; lblTitle.Width = 114; lblTitle.Height = 25; lblTitle.Font.Bold = true; pnlTitle.Controls.Add(lblTitle); // Build the role label control System.Web.UI.WebControls.Label lblRole = new System.Web.UI.WebControls.Label(); lblRole.ID = "lblRole"; lblRole.Text = _role; lblRole.Width = 108; lblRole.Height = 25; lblRole.Font.Bold = true; pnlTitle.Controls.Add(lblRole); // Build the Department label control System.Web.UI.WebControls.Label lblDept = new System.Web.UI.WebControls.Label(); lblDept.ID = "lblDept"; lblDept.Text = _department; lblDept.Width = 139; lblDept.Height = 25; lblDept.Font.Bold = true; pnlTitle.Controls.Add(lblDept); // Build the Top 5 // Button System.Web.UI.WebControls.Button btnTop = new System.Web.UI.WebControls.Button(); btnTop.ID = "btnTop"; btnTop.Font.Size = System.Web.UI.WebControls.FontSize.Medium; btnTop.Font.Bold = true; btnTop.BorderStyle = System.Web.UI.WebControls.BorderStyle.None; btnTop.ForeColor = Blue; btnTop.Text = ""; btnTop.Height = 25; btnTop.Width = 106; btnTop.BackColor = Transparent; pnlTitle.Controls.Add(btnTop); // Build the Department DropDown System.Web.UI.WebControls.DropDownList drpDept = new System.Web.UI.WebControls.DropDownList(); drpDept.ID = "drpDept"; drpDept.Height = 25; drpDept.Width = 176; pnlTitle.Controls.Add(drpDept); // Build the Expand and Collapse Button System.Web.UI.WebControls.Button btnExpand = new System.Web.UI.WebControls.Button(); btnExpand.ID = "btnExpand"; btnExpand.Font.Size = System.Web.UI.WebControls.FontSize.Medium; btnExpand.Font.Bold = true; btnExpand.BorderStyle = System.Web.UI.WebControls.BorderStyle.None; btnExpand.ForeColor = "Black"; btnExpand.Text = "V"; btnExpand.Height = 25; btnExpand.Width = 106; btnExpand.BackColor = Transparent; pnlTitle.Controls.Add(btnExpand); // Add the title panel to the Update panel upPanel.ContentTemplateContainer.Controls.Add(pnlTitle); // Build the datasource for the control System.Web.UI.WebControls.SqlDataSource sqlSource = new System.Web.UI.WebControls.SqlDataSource(); // Build the "Grid panel" control System.Web.UI.WebControls.Panel pnlGrid = new System.Web.UI.WebControls.Panel(); pnlGrid.i.ID = "pnlGrid"; pnlGrid.BackColor = "White"; pnlGrid.CssClass = "Parts"; pnlGrid.Height = 28; // Build the Datagrid to hold the data System.Web.UI.WebControls.DataGrid dgStuff = new System.Web.UI.WebControls.DataGrid(); dgStuff.ID = "dgStuff"; dgStuff.Width = 717; dgStuff.DataSourceID = "sqlSource"; dgStuff.AlternatingItemStyle.BackColor = "lightblue"; pnlGrid.Controls.Add(dgStuff); // Add the Data Grid to the Update panel upPanel.ContentTemplateContainer.Controls.Add(pnlGrid); // Add the update panel to the Container body.Controls.Add(upPanel); // Add the Data source to the Container body.Controls.Add(sqlSource); // The body is wrapped in a higher-level div HtmlGenericControl containerDiv = new HtmlGenericControl(); containerDiv.Attributes.Add("class", "ms-TPBody"); containerDiv.ID = "containerDiv"; containerDiv.Controls.Add(body); } /* protected override void RenderWebPart(System.Web.UI.HtmlTextWriter output) { MyBase.EnsureChildControls(); MyBase.RenderWebPart(output); } */ #endregion }}Any assistance would be appreciated. I am so close, colors always give me a rough time when setting values programmatically. I did not highlight all trouble lines above, any line which set a value for a color is generating an error. Bronco
vb.net or c#.net -----> which is the advantageous one?   (129 Views)
hii wan to know which language is more advantageous whether c#.net or vb.net if so please provide me the reasons.give the advantages and disadvantages of both vb and c#
I have a page that on which I need to capture the user's logon name   (148 Views)
I have an intranet site. On this intranet I have a page that on which I need to capture the user's logon name. I have tried page.user.identity.name along with several other ones that return the username on my development machine, but not on the server. Is there a way that this can be accomplished I want to allow anonymous access so that people don't get a username/password box when they try and access the site. Any advice is appreciated
Debugging the file which is read only.   (129 Views)
I have a asp.net application, which is read only, now i want to debug the application. So, How can i do the same.Thanking you,Thirumalaraj.
Re: Confused about which webserver to use   (144 Views)
I tried that it still is the same. I would like to thank who has helped so far. I feel alot closer to a solution now. Hopefully, we can get that last part solved.
how to delete a record which is using in another table   (146 Views)
hello,dears, i want to delete a value which is using in another table. but when i delete it an error occur.let suppose that,there is a table "tbl_TeamMembers" and another table "tbl_Role"and now i am using a record from "tbl_Role" the primary key of "tbl_Role" which is "Role_ID" in to the "tbl_TeamMembers" as a foreign key. if there is a record which is also in the "tbl_TeamMembers" and i want to delete it from "tbl_Role" it does not allow me to delete a record.please help me.byefaisal dar
which function can convert time value in universal time format.   (153 Views)
there r functions to get month,year but i couldn't find any function to get am,pm from a time value.one suggested thing is to have time in universal time format but i couldnt get any funtion which can convert '2:20 pm' to '14:20' universal time:8-0:
How to detect which user control initiates postback?   (137 Views)
On my webform I've got several user controls, each with a btnSubmit within them. (Some btnSubmits.visible will be False so one btnSubmit controls all controls) The reason we did this is so I can take the controls and put them wherever they need to go, and still get the same functionality. Problem we're having is whenever the btn in one user control is pressed, it does a postback which kinda messes up all the other user controls. We're hoping there is some way to detect which user control initiated the postback so we can find a way to prevent it. If anyone has an idea, please let me know.Many
which Machine.config in use??   (103 Views)
Environment - VB.NET, ASP.NET, SQL Server 2000. If I go to "C:\WINNT\Microsoft.NET\Framework\", I see multiple installation of .Net Framework. Each having its machine.config. How do I figure out which one in use by Visual Studio.NET Please advice.
how to access a file at the server which is posted to it by client   (176 Views)
hey, can any one please help regarding accessing a posted file at the server. my code goes like this: CLIENT: File input = new File("XMLFile1.xml"); RequestEntity entity = new FileRequestEntity(input); PostMethod post = new PostMethod(url); post.setRequestEntity(entity); HttpClient httpclient = new HttpClient(); try { int result = httpclient.executeMethod(post); if (result >=200 && result
Error insertparameters :expects parameter which was not supplied (VB)   (191 Views)
I'm facing this error when I'm trying to insert a new register via gridview (vb).I'm using sql server and the sp is ok... the update and delete operations is working fine. The procedure to include a new register is locate on the gridview footer template. Protected Sub fs_InsertClick(ByVal sender As Object, ByVal e As System.EventArgs) Dim selectedRow As Image = DirectCast(sender, Image) Dim ws_cod As TextBox = CType(selectedRow.FindControl("txtcod"), TextBox) Dim ws_desc As TextBox = CType(selectedRow.FindControl("txtdesc"), TextBox) Dim ws_nome As TextBox = CType(selectedRow.FindControl("txtnome"), TextBox) SqlDataSource1.InsertParameters.Clear() SqlDataSource1.InsertParameters.Add("WT001_Empresa_Cod", ws_cod.Text) SqlDataSource1.InsertParameters.Add("WT001_Empresa_Desc", ws_desc.Text) SqlDataSource1.InsertParameters.Add("WT001_Empresa_Nome", ws_nome.Text) SqlDataSource1.InsertParameters.Add("WT001_Empresa_DePara", ws_depara.Text) SqlDataSource1.InsertParameters.Add("WT001_Empresa_RegUser", lblRegUser.Text) SqlDataSource1.Insert()
which database is best for my project in vs08 using asp.net ?   (159 Views)
which database is best for my project in vs08 using asp.net and why
How to determine which browser a client is using   (141 Views)
We have been asked about browser sniffing and wanted to know if anyone knew of a way of doing it in ASP.NET, it is for using different style sheets depending on which browser they are using. help would be grateful.
which is better Session,Cookies or Querystring?   (120 Views)
ok! I need to develop a website,that acts as travel agents [book tickets,cancel them & make alterations]. for the Login page which is better use session use cookies or anyother you know also i would be using something like this.. i would show the Bus [Pic] for the travel in top view .The booked tickets would be grayed out and the tickets available should can be booked by someone. I dont understnd how to go about it any roadmap that someone can give me so that the website development process goes as expected Any tips would be helpful.. This post has been edited by gokujames: 14 December 2009 - 09:57 PM
how to load aspx page which is include listview in Masterpage   (148 Views)
i have solved this problem using User Control method. now i have put content of the page inside uc1 and used the below code to call the page at the update panel: once the user click on the related button i just change the Visible option to True. i hope it would be helpful.
Stored Procedure(Sql) expects parameter which was not supplied   (86 Views)
all. Bit of an issue I'm having with unique identifiers. Here is the code for declaring the parameters, and executing the stored procedure. public static System.Data.DataTable GetRealtorTable(System.Data.SqlClient.SqlCommand a_sqlCommand, System.Web.Security.MembershipUser a_memUser) { a_sqlCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@realtorID", System.Data.SqlDbType.UniqueIdentifier)); //Declare Parameter a_sqlCommand.Parameters["@realtorID"].Value = new System.Guid(a_memUser.ProviderUserKey.ToString()); System.Data.DataTable f_dataTable = new System.Data.DataTable(); System.Data.SqlClient.SqlDataReader f_dataReader; DataReaderAdapter f_dataReadAdapt = new DataReaderAdapter(); a_sqlCommand.Connection = m_dbConnection; f_dataReader = a_sqlCommand.ExecuteReader(); //Here is where the error occurs. f_dataReadAdapt.FillFromReader(f_dataTable, f_dataReader); //Clean Up f_dataReader.Dispose(); f_dataReadAdapt.Dispose(); return f_dataTable; } Here is the stored procedure. ALTER PROCEDURE dbo.sp_GetRealtorByID /* ( @parameter1 int = 5, @parameter2 datatype OUTPUT ) */ ( @realtorID UniqueIdentifier ) AS SELECT dbo.tblRealtor.* FROM tblRealtor WHERE tblRealtor.[Realtor ID] = @realtorID /* SET NOCOUNT ON */ RETURN Any one know why SQL seems to loose track of my parameter Sincerely, Stormin This post has been edited by StorminNorman: 16 November 2010 - 11:20 PM
.NET 4 running two sites 1 = TEST, 2 = Production, can I tell which is which in global.asax   (277 Views)
I don't want to get the two sites mixed up. I have 2 SQL databases as well. so I need two connection strings. Is there a way to have an 'IF' statement in the global.asax file to tell which folder on the server the global.asax file is sitting in when it runs, then set Session(WhereAmI") = . is there a way to do this somehow IF folder = "TEST" then Session(WhereAmI") = "TEST" Else Session(WhereAmI") = "Production" End if DougP
asp.net 4.0 vb gridview multi button in columnsl how to tell which button clicked   (127 Views)
I have a gridview with several columns each containing one button. I can get the row id but not the column id or the button caption.I made them all Select buttons which is the only way it will work on a hosted WEB site.any other type of button and the GridView1_RowCommand dose not fire.I just want 3 buttons and know which one I pressedCODEPrivate Sub GridView1_RowCommand(sender As Object, e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles GridView1.RowCommand Dim index As Integer Dim selectedRow As GridViewRow index = Convert.ToInt32(e.CommandArgument) selectedRow = GridView1.Rows(index) Me.lblName.Text = selectedRow.Cells(0).Text ' the following 6 lines are code I got from another WEB teh rem'ed out lines don't work Dim currentCommand As String = e.CommandName Dim currentRowIndex As Integer = Int32.Parse(e.CommandArgument.ToString()) 'Dim ProductID As String = GridView1.DataKeys(index).Value 'this gives error Label1.Text = "e.CommandName: " & currentCommand Label2.Text = "e.CommandArgument.ToString: " & currentRowIndex.ToString 'Label3.Text = "GridView1.DataKeys(index).Value: " & ProductID Dim cnn As SqlConnection Dim cmd As New SqlCommand cnn = New SqlConnection(gblconnectionString) Try cnn.Open() With cmd .Connection = cnn .CommandText = "Attend" .CommandType = CommandType.StoredProcedure .Parameters.AddWithValue("Lastname", Me.lblName.Text) .Parameters(0).SqlDbType = SqlDbType.Text Debug.Print(e.CommandName) Me.lblRowNumber.Text = e.CommandName.ToString If e.CommandName.ToString = "Select" Then .Parameters.AddWithValue("Present", "P") .Parameters(1).SqlDbType = SqlDbType.Text 'ElseIf e.CommandName = "Absent" Then ' .Parameters.AddWithValue("Present", "A") ' .Parameters(1).SqlDbType = SqlDbType.Text Else .Parameters.AddWithValue("Present", "T") .Parameters(1).SqlDbType = SqlDbType.Text End If .ExecuteNonQuery() End With Me.GridView1.DataBind() Catch ex As Exception MsgBox(Err.Number & " " & Err.Description) End Try DougP
using asp.net or php, which is better for search engines?   (196 Views)
, my company is interviewing a person to help us in our organic google listings. Our site is currently programmed using asp.net on windows server. The guy that is trying to earn our business claims the following:This info is third hand so please forgive the writer as she doesn't understand that Linux=php and ASP.NET = windows.CODE> 1. Switch our website from an ASP server to a Linux server for several>reasons:> a. Data can be organized so that search engines can spider our site>effectively. Right now that is not the case. For ex: any images we have>on our site prohibit the search engines from finding the keywords around>and after those images. With a Linux server, the search engines won't>even know the images are there. By the way, images don't help us at all>with optimization.> b. The search engines prefer Linux to ASP because they can read them>better and give extra 'points' towards optimization for those websites who>utilize Linux.> c. The style sheets can be separated and allow for spiders to flow>through our entire site easily.> d. ASP does not work well with the Mozilla Firefox browser, a>fairly popular one, and it causes verbage and images to be off kilter and>look sloppy. That won't happen with Linux.> 2. They have stated that the Coding of our site is very poor and outdated,>tags used to code the site by search engines are no longer supported in>the W3C (World Wide Web Consortium), which makes our web pages invalid to>today's standards. In fact they found 233 standard errors on the home>page alone, all of which hurt us in organic optimizationcan anyone confirm thi
Comparision of asp.net and jsp which is best   (86 Views)
My company is at the point of redveloping our current intranet from asp with an ms sql db. My manager has not decided yet what language to use to develop it, though we will be using win 2003 server for the platform. My own suggestion is .net with MS SQL server, but my collegue wants to develop in java with a LDAP database (I assume jsp). We are suppose to come up for reasons to go either way. Not knowing enough about jsp now (I did a java course about 8 years ago so am pretty rusty with how far its come!). I wonder of anyone can point me to articles giving comparisions of both, or suggesting why we should go either way. The site is mainly a company intranet for looking up details of people, companies and contracts