Hi guys , I came across a piece of code similar to the below one. public partial class Form1 : Form { private void Form1_Load(object sender, EventArgs e) { ad test = new ad(); Ia id5 = test.testobj(); id5.display() } } public interface Ia { void display(); } public class b : Ia { public void display() { MessageBox.Show("do it man"); } } public class ad { public Ia testobj() { b gh = new b(); return gh; } } My question is why should we typecast object gh to interface Ia in testobj() function as the interface object when we can directly use the object of class b to call display function. Thans in advance, sishya -- modified at 5:54 Friday 27th April, 2007
sishya
Posts
-
use of assigning the object impelementing a interface to an interface [modified] -
Hi by using access database and i am facing lot of problemsHi i am using access in my webapplication.I am facing a lot of problems like connection already open.My question is why MS access is not suitable for web application ? Thanks and regards
-
Inheriting page controls rendered from base page to inherited pageHi , I have created a page which basically parses a xml file and populates the page accordingly .Now the problem is inorder to provide more flexibiliy i need to allow any page to inherit this base page,but on inheriting the class and executing it the base page controls are not visible.I undestand it cant be done by that way.Then pls suggest a solution.I doubt the same can be done with master page. Thanks in advance,
-
problem with transforming only a part of xml fileHi guys, i am transforming an file called XMLFile.xml along with the appropriate xslt file like this: XPathDocument surveyDoc = new XPathDocument(Server.MapPath("XMLFile.xml")); // Load the xslt to do the transformations XslTransform transform = new XslTransform(); transform.Load(Server.MapPath("dynamicControls.xslt")); // Get the transformed result StringWriter sw = new StringWriter(); transform.Transform(surveyDoc, null, sw); But the xmlfile.xml contents are like: details followed by another form details. details so i want to specify the required formname in new XPathDocument=(Server.MapPath("XMLFile.xml")); //i.e BusinessUnit for ex: not the entire xml file how can i pass only the required xml content(i.e only a part of the xml file containing required form details) want for transformation.I.e i dont want to transform foreign unit part also within the xml file.Please throw some light on this. Thks in advance, -- modified at 9:48 Sunday 16th July, 2006
-
Problem with transforming a part of xml file [modified]Hi guys, i am transforming an file called XMLFile.xml along with the appropriate xslt file like this: XPathDocument surveyDoc = new XPathDocument(Server.MapPath("XMLFile.xml")); // Load the xslt to do the transformations XslTransform transform = new XslTransform(); transform.Load(Server.MapPath("dynamicControls.xslt")); // Get the transformed result StringWriter sw = new StringWriter(); transform.Transform(surveyDoc, null, sw); But the xmlfile.xml contents are like: followed by another form details. details so i want to specify the required formname in new XPathDocument=(Server.MapPath("XMLFile.xml")); //i.e BusinessUnit for ex: not the entire xml file how can i pass only the required xml content(i.e only a part of the xml file containing required form details) want for transformation.I.e i dont want to transform foreign unit part also within the xml file.Please throw some light on this. Thks in advance, -- modified at 6:56 Sunday 16th July, 2006
-
sorting dataView by using ordinalHi till now i had been using a contol which used to take sql statement for sorting . the sql statement looked like "select * from emp order by 2 desc" But now i am using a dataset which i am getting thru executing a stored procedure. I am converting dataset into dataview and maintaining its view state But the problem is i have to sort like the above sql command by ordinal. is it possible to do the same in dataView.If so pls let me know how to do it. thks in advance
-
Custom contol not working with asp.net 1.x (If i use dll working properly)using System.Web.UI.Design; public sealed class DataGridNavigationBarDesigner : ControlDesigner { public override string GetDesignTimeHtml() { System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append("
"); sb.Append(""); sb.Append(""); sb.Append(""); sb.Append(""); sb.Append(""); sb.Append(""); sb.Append("
Number of rows
Page size "); sb.Append("
Current page
"); sb.Append("
"); sb.Append("
"); sb.Append("
"); sb.Append("
"); sb.Append("
"); sb.Append("
"); return sb.ToString(); } } The error is during compilation it says cannot find System.ComponentModel.Design; and using System.Web.UI.Design; but since i have the dll it works fine .But i have to do changes to it. Pls suggest solution(alternatives for the same) thnks in advance.
-
Problem using expressionsHi, in xslt i have written an template where in i have created text box(txtbx2) and binded a value as follows: but on running it i get an exception that scripts cant be run.Pls help me out
-
Inheriting controls from a web page(asp 1.0)hI, I have a web page in which i am generating all the controls dynamically .I have a place holder(also dynamically generated)in webform1 into which i am pushing all the All the generated controls . Now i want ato inherit this page into webform2 .What i tried was public class Webform2 : webform1 in webform class i have a ftion public void look() { // Response.Write("look"); PlaceHolder pl = new PlaceHolder(); TextBox tb; tb = new TextBox(); tb.Text = "adarsh"; tb.Visible = true; tb.Width = Unit.Percentage(20); tb.Height = Unit.Percentage(20); pl.Controls.Add(tb); this.form1.Controls.Add(pl); } } in webform2 class i call page load event i call this ftion look .But it gives a runtime exception saying in line this.form1.Controls.Add(pl); object reference not set to an instance of an object.Why is this and pls suggest any solution for this. -- modified at 1:54 Monday 3rd July, 2006
-
problem with inheriring a pageHi, Since the placeholder is declared in the code behind then why is it not displaying. Is there a way out to inherit the controls(in .net 1.0) from one page to another so that we can use it as a master page as in .net 2.0.
-
problem with inheriring a pageHi, i have a page by name public class webform1: System.Web.UI.Page (webform) which is basically a page which dynamically generates controls .The users have to inherit the page if they want the same format of the default page (controls) so what i did in webform 2 was public class webform2 : webform1 in the webform1 i have declared the place holder pl1 where i have all the controls pushed in .On running webform2 i dont see the controls present in webform1.(webform1 is running fine with cntls being displayed) pls help me out
-
Problem with dynamic controlshi, i have given this piece of code in page Load() { DDLSortBy=new DropDownList (); DataSet ds=new DataSet (); da.Fill(ds); DDLSortBy.DataSource = ds.tables[0] DDLSortBy.DataTextField = "EmpId"; DDLSortBy.DataValueField = "EmpId"; DDLSortBy.DataBind(); DDLSortBy.SelectedIndex = 0; DDLSortBy .AutoPostBack = true; DDLSortBy.SelectedIndexChanged += new System.EventHandler(DDLSortBy_SelectedIndexChanged); plFrm.Controls.Add(DDLSortBy); } i am able to retain the value(view state) of the text box inspite of the DDL getting initialized each time on postback.I see no difference if initialize the controls on OnInit() function. Then why many articles in net suggest us to dynamically add controls in init ftion() . -- modified at 1:11 Wednesday 28th June, 2006
-
Problem with dynamic controlsHi, adding within controls inside form tag is not under my control unless i use addat function. Moreover pls help with retaining the view state .Many say that it should be added in the init ftion.But still doesnt work.Pls write a small snippet if possible because couldnt find a suitable link i require in net.
-
Problem with dynamic controlsHi, i have written following code TextBox tb = new TextBox(); tb.Text = "ghjhgjh"; Label lbl = new Label(); lbl.Text = "Hello, World!"; lbl.Font.Bold = true; Controls.Add(lbl); Controls.Add(tb); foreach (Control c in Controls) Label1.Text += c.ToString() + " - " + c.ID + "
"; but on running i get the following exception --> Control 'ctl03' of type 'TextBox' must be placed inside a form tag with runat=server. also please explain how to retain the view state of the text box. -
To maintain the view state of a dynamically created controlI created a drop downlist dynamically and i am unable to capture its values i.e its view state. I know that view state can't be retained for dynamically created controls .pls suggest a way out to retain the view state.
-
creating customizable datagrid reading an xml fileHi, i have asked to create a user control for master page which basically parses an xml file and decides things like if the datagrid has paging or not and if the datagrid can be edited or not. I dont have much idea as to how to start of with.Can anyone throw light on this or suggest few related links. thnks in advance.
-
displaying a div dynamically whereever dropdownlist Box is present above it. [modified]The div tag is not present anywhere in the webform and has to be created on mouseover of the dropdownlist
-
displaying a div dynamically whereever dropdownlist Box is present above it. [modified]Hi, new to DOM .Pls help me out .Is there anyway out other than this.
-
sry fr trouble , 1 more doubt about date storageHi, i many of the projects which went on the production server (uses sql server 2000)of other countries there was a common exception in all of them.It is the date conversion exception.Many suggest the way to do it is to use culture attribute to store date in the sql server .Not shoor about it.Please suggest a way to store the date in the sql server such that no problem would arise in future projects. Thnks and regards,
-
not sure of advantages of functions over stored proceduresHi, I am asked to convert stored procedures to functions .Can anyone tell me the advantages of functions over stored procedures and vice versa and i am not shoor if i can use system ftions like getdate() in functions pls help me out thnks in advance.