|
This is a basic question. When would one decide to make an user control and when would you want to add the controls to the aspx page itself?
My idea was that whenever you want to add some new event to the existing control/s you would make use of the control and then add events to it. But is there any other reason why you would want to make a new control?
Also if i dont need any new events, all i do is put all the controls (that normally i would put in aspx page) in a ascx page and then just add this to my page - would i get any benefit ? like in performace?
Any help will be greatly appreciated ..
|
|
|
|
|
My biggest reason for using user controls is ...reusability.
For example, I have a "Departments" dropdown list that pulls its data from a database. If I only use this on one webform, then maybe I'll just use a dropdownlist on that one form and code to populate it. But using it on many web forms, I get a benefit from creating/coding it once as its own user control, then using the user control on each of the web forms.
|
|
|
|
|
ummm.. makes sense. But then would i get any other benefit? I could always paste the same code without any changes.
|
|
|
|
|
Yes, you could always copy/paste the same code several times.
On the other hand, if you ended up needing to make a minor change to that "Departments" dropdown, would you really want to have to make the change several times? Setting it up as a user control in the first place ensures that you only have to change it once.
|
|
|
|
|
ah ok.
The reason I am really confused is that I have joined this new project where they insist on making controls for each and every page. None of them can be reused as they are making one ascx page for one aspx page. I just wanted to figure out if doing so is adding any advantage or is this just some kind of design that just deosnt make any sense to me
-- modified at 17:38 Wednesday 9th August, 2006
|
|
|
|
|
Oh. I'm not sure why they would want to make each page a single .ascx. I don't see any advantage to that. Unless the goal was to have a single .aspx page that could dynamically swap out any of a number of .ascx's, I suppose... but otherwise, I can't think of a reason to do it that way.
Have you asked your project partners? What reason do they give?
|
|
|
|
|
oh the guy who is the decision maker is working on .NET for the first time and i have no idea why he insists on making use of such things just because its a part of the technology or because he's new to it or because he just is complicating things
when asked all he says is that we might use it some day. So i was wondering if you know there really is some advantage behind just creating so many user controls.
|
|
|
|
|
I'd say it's good practice to build controls in such a way that promotes reuse, even if the possibility of reuse hasn't yet become apparent. May as well write it in a way that's most likely to help you later. Building each page as a single control makes sense only if you're using ASP.NET 1.1 and you need multiple pages to be hosted in one URL, so they can share viewstate.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
hi shilpa,
I have also work on a project which is contain all user controls ecexpt on aspx web page which is load every user controls.
I thinks lots of advantage
like reusable is comman advantage and One of most advantages of user controls is that they can expose properties and methods like any object in the .NET Framework.
|
|
|
|
|
Hi.
I have an application developed using VB. The application is installed on the server and until recently I was updating it when needed without problems.
Yesterday I had to make new updated to the app. After I completed my updated and release both application and the set up project I removed previous version from the server and ran my new set up. When the set up was complete in the installed projects (Control Panel) I saw my application being installed (takes about 32 mg) but folder in the wwwroot was empty and of course the application didn't work because default and all other files (dlls too) are missing.
Did anyone have such a problem? I think there's something wrong with the permission (IIS) when I install the application. The installer works on my machine and all other machines as well.
There was something installed on the server recently and I think it did something that causes this to happen.
Thanks Alex.
|
|
|
|
|
Just make sure that IIS is pointing to the right folder.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Looks like it is.
When the install didn't drop any files into the application folder in wwwroot I copied all the files into the directory from one of the machines I was testing on. As soon as I did that the application was functional (so I guess IIS points to the right folder). I checked the IIS setting anyway to make sure. Strange.
|
|
|
|
|
Hello,
I am trying to convert this application I am working on from ASP.NET 1.1 to 2.0, and certain things are not working as they should. One thing is the code below
<br />
TextBox txtCompleted = new TextBox();<br />
TextBox txtProjected = new TextBox();<br />
position = j+1;<br />
CheckBox chk = Page.FindControl("chk_"+ j + "_" + ContractNum) as CheckBox;<br />
txtCompleted = Page.FindControl("txtCompleted_"+j+"_"+ContractNum) as TextBox;<br />
txtProjected = Page.FindControl("txtProjected_"+j+"_"+ContractNum) as TextBox;<br />
<br />
completed = txtCompleted.Text.Trim();<br />
projected = txtProjected.Text.Trim();<br />
CheckList_ID = int.Parse(CheckListID.Rows[j]["ID"].ToString()); <br />
<br />
In .NET 1.1 completed and projected get the values of the text boxes after the user clicks save, but in 2.0 this doesn't seem to work, I was wondering if anyone had any suggestions.
Sincerely,
The Major Rager
|
|
|
|
|
TheMajorRager wrote: txtCompleted = Page.FindControl("txtCompleted_"+j+"_"+ContractNum) as TextBox;
txtProjected = Page.FindControl("txtProjected_"+j+"_"+ContractNum) as TextBox;
If these controls already exist on your page why not call them directly rather than use FindControl?
only two letters away from being an asset
|
|
|
|
|
AS well as the previous comment, why would you write code that calls FindControl and has no block to make sure that it succeeded ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hello,
I am using below code for sending emails, I am getting email in mailroot queue, my system is connected to internet, what settings need to be done so email can send to valid email Id.
Imports System.Web
Imports System.Web.Mail
Function sendMail(ByVal i_strFromId As String, ByVal i_strToId As String, ByVal i_strCCId As String, ByVal i_strSubject As String, ByVal i_strMsg As String)
Dim objMail As New MailMessage()
If Len(i_strFromId) > 0 Then objMail.From = i_strFromId
If Len(i_strToId) > 0 Then objMail.To = i_strToId
If Len(i_strCCId) > 0 Then objMail.Cc = i_strCCId
objMail.BodyFormat = MailFormat.Html
objMail.Subject = i_strSubject
objMail.Body = i_strMsg
SmtpMail.Send(objMail)
End Function
Best Regards,
S Kumar
|
|
|
|
|
Set the SmtpMail.SmtpServer property to a valid email server
only two letters away from being an asset
|
|
|
|
|
Hello,
I had tried with SmtpMail.Smtpserver = "mail.valid.com" ' Valid smtpmail server
then also it is not working
Any setting require for SMTP server like SmartHost or anything ?
Please advise.
Best Regards,
S Kumar
|
|
|
|
|
When you say "is not working" what do you mean? Are you getting an exception, is the mail not being sent?
only two letters away from being an asset
|
|
|
|
|
Hi,
I am getting email in Mailroot/Queue, if I am using valid email id it is not sending email.
Regards,
SKumar
|
|
|
|
|
In the web.config, add a key under appsettings. The value should be the ip address of the machine which is hosting. If local machine, then put localhost.
<add key="smtpServerName" value="192.104.100.100"></add>
Then in your sendmail function add one more line before smtpmail.send.
SmtpMail.SmtpServer = ConfigurationSettings.AppSettings("smtpServerName")
SmtpMail.Send(objMail)
Regards,
Raghu.
|
|
|
|
|
How do I get photos to appear in a sql database using visual web deleloper? PLease see web site www.mkra.dnh.sk
Regards,
|
|
|
|
|
Normally, the way to do it is to store the path to the image in the database and store the image in the file system.
|
|
|
|
|
I am having terrible troubles at work trying to insert a parameter from a FORM into the Datagrid SELECT statement in ASP. I have searched MSDN knowledgebase, read and used examples, and am still having troubles.
Some details: I'm using the drag and drop method of inserting data from Visual Studio 2005 Database Connections from the table. I am using SQL Server 2005 and Visual Studio 2005 with .NET 2.0. I can get the data to display in the datagrids STATICALLY, but I need them to display dynamically using a parameter passed from the FORM control.
Some example code:
http://www.campus.ncl.ac.uk/databases/dotnet/aspdotnet2.html[^]
The only thing I need is for the code to have a FORM to enter a string or data and a datagrid that uses that parameter from the FORM inserted in the SELECT statement of the datagrid.
-Jesse Myer
-- modified at 11:11 Wednesday 9th August, 2006
|
|
|
|
|
Are you using c# or vb for your code behind?
|
|
|
|