C# - How To Call Class & Method From A Button In Another Class
Jun 24, 2010
I have a WindowsForm that has a DataGridView that shows output of my app. The class with the button is DriveRecursion_Results.cs. I want it so that once the button is pushed by the user, my method FileCleanUp() in my SanitizeFileNames class is called. I'm not quite sure how to do this though.Here is the code for both classes:
public partial class DriveRecursion_Results : Form
public DriveRecursion_Results()
InitializeComponent();
private void listView1_SelectedIndexChanged(object sender, EventArgs e)
[code]...
I have created an extended method for DataTable. I want to generate a class automatically in my solution when i call that method while writing a code as Visual studio does when it doesnt find the method.e.g mytable.mymethod(); Generate a class
I wrote this code in class.cs. But I want call it’s from default.aspx.cs
public ArrayList GetInfos(string NAM) { ArrayList list = null; if (ViewState["ArrayData"] == null) { list = new ArrayList(); string str = ConfigurationManager.ConnectionStrings["conString"].ConnectionString;
I am building a web site with visual web developer 2010
I have a class (autoButton) that adds a button to a panel (on Default.aspx) and a handler w/i the same class (classifyEventHandler)
The button appears fine, but when clicked the even doesnt fire, what am I doing wrong?
I tried locating the event handler in default.aspx, but it was not found :P
Imports Microsoft.VisualBasic Public Class autoButton Public Sub makeClassifyButton(ByVal theCell As Object) Dim myButton As New Button myButton.Text = "classify" myButton.ID = "b_classify_" + theCell.ID AddHandler myButton.Click, AddressOf classifyEventHandler theCell.Controls.Add(myButton) End Sub Private Sub classifyEventHandler(ByVal sender As Object, ByVal e As EventArgs) MsgBox("done?!") End Sub End Class
I am beginner in web applications development. I started one little project and host it on source forge "https://homoco.svn.sourceforge.net/svnroot/homoco". And I started implementing authentication in this application to learn how it works. From my experience people never use out of the box things so I want to implement this stuff alone (like in real world projects). So some questions:
1) Is there any reason to use membership out of the box? To use database table schema, stored procedures etc. that tool generate for developer. I think that this lower control over code and I decided to implement it my self. I don't know if I am right.
2) Is my approach in this demo project good or bad (if someone have time I like to do just a little code review)? I created database based on business rules. Not using database schema that membership provider require. Extend "MembershipProvider" class to satisfy my needs. Implement queries to database myself.
3) Now, this question is a little wired but I have to ask it. If we make custom Membership Provider and do sql queries alone, implement all MembershipProvider class methods ourselves, and in application use Membership.blabla() why is this approach different from not extending MembershipProvider class and putting all this methods in some unique class and call its methods then? I hope that someone understand what I ask here.
I am sorry for three questions, but I really trying to find the best way to implement this feature in my demo project like it is a real world application.
I have created my own custom role provider class "SGI_RoleProvider" and configured properly.
Everything is working fine.
Suppose that I have added a public method say "SayHello()", then how can i call that. Because if i am using Roles then the method is not displayed. If i am forcefully using that Roles.SayHello() then compiler gives the error.
how can i call this. Because creating a new instance of SGI_RoleProvider is meaningless.
I am new in asp .net.I am not able to undestand why we call base class method when we override methods/events.Like automatically visual studio will put base.OnInit() if you are overriding OnInit.
I have an ObjectDataSource that I want to perform updates using a business entity i.e. Type="Object"). Since the values for the entity are within a user control, I have stored a reference to the control in Session and in the updating event, set the new instance to the value of the entity from the user contol property (which also pulls values from the form viaother properties of the control):
Protected Sub MasterDataSource_Updating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ObjectDataSourceMethodEventArgs) Handles MasterDataSource.Updating Dim entity As New Login() Dim accountControl As AccountInfo = TryCast(Session("AccountCtrl"), AccountInfo) entity = accountControl.Entity e.InputParameters.Add("entity", entity) End Sub
My question is, how can I get the update method to pass this entity to the update method in my BLL class? It seems the Update method requires an ID or reference to the original object to use in determining whether any changes have taken place, but I don't really want to do this. In other words, I just want to use the Update event on my ObjectDataSource to pass my entity to the method ("Update") I set as a property and then let this business method handle the update of the data. Shown below, is the BLL update method I want to call:
Public Overloads Function Update(ByVal entity As Login) If entity Is Nothing Then Throw New ArgumentNullException("entity") End If MyBase.Update("UpdateLogin", entity.Username, entity.Password, entity.FirstName, entity.LastName, entity.Role, entity.Region, _ entity.Email, entity.Title, entity.TierID, entity.Street, entity.City, entity.State, entity.Zip, entity.Mobile, entity.Phone, entity.Fax) End Function
When I try to call this as it stands now, I get an error: ObjectDataSource 'MasterDataSource' could not find a non-generic method 'Update' that has parameters: ID, entity. Previously, I'd set up a long list of parameters of basic data types (string, int, boolean), but this is rather cumbersome and I was hoping to use an entity for this (FYI, I also got the same type of error when I tried this approach, but with the ID as the last parameter in the list). Perhaps what I'm doing here is atypical to how the ODS is normally used?? Has anyone done something like this successfully?
how to jquery call a other call function other class is not static
[WebMethod] public static bool Verify(string username, string password) //Do your logic with username, password here //I am just checking with admin/admin credentials Console.WriteLine("Ritu"); [code]...
Currently, only GenericOfflineCommentary's ExtractPageData() is firing. How can I modify this to first run OfflineFactsheetBase's ExtractPageData() and then GenericOfflineCommentary's?
edit: I'm trying to avoid having to call base.ExtractPageData() in every implementor.
So I have Test1.aspx, Test1.aspx.vb. The LocalResource files, in the App_LocalResources folder, Test1.aspx.resx and Test1.aspx.es.resx. I also have a class called TestTheData.vb in the App_Code folder.
Now what I want to do is call GetLocalResource("stringObjRes").ToString in the TestTheData.vb class. The method however is not showing up in Intellisense. When I try to type manually, I get the error lines in my code.
I've imported:
Globalization Threading Threading.Thread Web Web.UI.Page.
I have created one class and use in default.aspx page working well. But when i add new aspx page and trying to call there i am getting error.
Code: Parser Error Message: 'project1._Inquiry' is not allowed here because it does not extend class 'System.Web.UI.Page'. Below code is from default.aspx header.
k Code: <%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="project1._Default" %>
Below is the code of second file where error appear.
ss Code: <%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Inquiry.aspx.vb" Inherits="project1._Inquiry" %>
I'm trying to call a base class specifically; Release class into a Page_load method.The release class is linked to a baseclass which contains a method Dataset GetresultHow do i call from the release class into the page load and use GetResult.
I have a web form with lots of code behind a button. I want to create a class, put all the code form the button into the class. But how do you call routines in the button from the class?
I'm building a menu controller class and I have a database with the Controller/Action strings in it. I want to dynamically build a menu reading from the database and generating the URLs to use in the menu's <a href=''> HTML that the class renders. I can't use Html.Action() in my class. I've tried adding System. Web.Mvc, but this doesn't help. Is there a way to generate a page's URL when given the Controller and Action? Maybe referencing the MVC equivalant of HttpContext.Current like I used to do in WebForms?
I would like to know how I can create a class that consists of my database connection and then how I can call that class within my C# code. Consider simple database call as follows,
I have a class that is referenced in my application. I use it in the codebehind, but now I need to call it from javascript. Is this possible, and how would I go about doing this? Say I have ClassABC. Within the class is method called getNames(). How do I call the method getnames() from javascript.
I wants to create a class file which contains the information about the salary calculation and call it on my page. hra,da,medical every thing is defined in percentage in that class and on my web page when i insert the basic salary in a textbox and click the button it will show the whole salary on a label.
I want to call css class that load background-image, font style,font size and so on...at the same time the code will load the button dinamically from database.. so that i want to put the CSS class, to change their image button when it default also when it hover.
If my class has NO destructor, an it goes out of scope. GC runs at certain time, now will it simply reclaim memory from my class OR will it call its destructor or Finalize () on it? And does the .net framework class like SQLConnection implement a destructor? I saw it has a Dispose () implementation but didn't see the destructor using "Go to definition".
Inside my application I created the following class
Code: Public Class clsProject
Public Sub AddData(ByVal cproject As string) ... end Sub end Class
I want to call this procedure from a sub in a form. So in the code behind file I wrote
Code: Imports TextMgmt.clsProject Public Class WebForm1 Inherits System.Web.UI.Page Protected Sub btnAddData_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnAddData.Click Call clsProject.AddData(txtInput.text) End Sub End Class
I get the following design time error: Reference to a non-shared member requires an object reference.I thought making things Public would make them visible.