|
There are about 10 pages in my project which are used to populate reference tables and each page needs to have text boxes to input data and format (i.e. number of text boxes, format of data etc) So I want to make a user control for data entry and place in all pages so that I dont have repeat the same code. But I not very comfortable with events and delegates and also passing data to and from a user control and webpage. Can someone suggest me code or some links which help me in doing this.
Thanks
Uday
Uday
|
|
|
|
|
Any book on ASP.Net 2.0 should have examples of this.
I would also suggest that you are making things more difficult than need be. What is wrong with having 10 pages to update 10 tables? That seems like good design to me. Putting code to update 10 tables in one user control seems like a terrible idea. Why take something simple and make it complex like that?
Think about this. If you don't touch this application for a couple years and you have to modify one of these reference tables. If you have one page per table, think how easy it will be to maintain! If you have some fancy trickery to put all the code in one user control think about how much more difficult it will be to dive back into the code. Just my two cents...
I didn't get any requirements for the signature
|
|
|
|
|
No no I am not trying to put whole code to update 10 tables in same user control's code. Since the html part is same in all the pages I thought of having it in a user control and have a save button on it. When user clicks save then I thought of handling that event on the web page to save the data. Not sure if this is the right way.I am new to .Net It is really simple when I have the html part on all pages but I want have it in one place and reuse it.
Uday
|
|
|
|
|
Sorry I misunderstood. Here are some tips for you. Create a public property for any control in your user control that you want to use in the page. And vice versa. Most books will give you an example of using userControl.FindControl("id"). But I find it cleaner and easier if just create a public property.
As for events... In the page_init of the page containing the control is where you set the event. Here is a quick example...
Good luck.
<br />
public partial class WebUserControl : System.Web.UI.UserControl<br />
{<br />
public Button submitButton<br />
{<br />
get { return this.Button1; }<br />
set { this.Button1 = value; }<br />
}<br />
protected void Page_Load(object sender, EventArgs e)<br />
{<br />
<br />
}<br />
<br />
protected void Button1_Click(object sender, EventArgs e)<br />
{<br />
<br />
}<br />
}<br />
<br />
<br />
public partial class _Default : System.Web.UI.Page <br />
{<br />
protected void Page_Init(object sender, EventArgs e)<br />
{<br />
this.WebUserControl1.submitButton.Click += new EventHandler(submitButton_Click);<br />
}<br />
protected void Page_Load(object sender, EventArgs e)<br />
{<br />
<br />
}<br />
<br />
protected void submitButton_Click(object sender, EventArgs e)<br />
{<br />
Response.Write("event handled");<br />
}<br />
}<br />
<br />
<br />
I didn't get any requirements for the signature
|
|
|
|
|
Todd thanks for your response I could access my the controls on a user control this way. Can we also access if the user control is on a master page?
Uday
|
|
|
|
|
Yes.
I didn't get any requirements for the signature
|
|
|
|
|
|
Cache.Remove("name");
Cache.Insert("name", sh.items, null, DateTime.Now.AddMinutes(60), TimeSpan.Zero);
I didn't get any requirements for the signature
|
|
|
|
|
When I run a website project within the ID, I get the "Connection Interrupted" message. What am I doing wrong?
[EDIT] It's a two-part problem. I'm using Firefox 3 as the "browse with" setting in the IDE. Firefox is changing the host name from "localhost" to "www.localhost.com", and the VS2008 IDE is decrementing the actual port number by two before running the browser.
So, I get this:
http://www.localhost.com:49230/Default.aspx
instead of this:
http://localhost:49232/Default.aspx
I also tried it with the both the internal browser and IE7, and while the host name issue is gone, the port is STILL wrong.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
modified on Monday, September 22, 2008 12:52 PM
|
|
|
|
|
I had the same issue. Do you have Nod32 anti-virus installed? Are you using Vista? If yes, problem is with protocol filtering. If you can, stop the anitivirus program. Or you can configure Nod32, so that it won't do this.
|
|
|
|
|
hi
how can change my caption depends on my language selection
that is my default language is English so while my page is loading my caption are display in english if i m change my lang. in run mode i hav to display all captionj in selected lang.
plz shar ur ideas
with regards,
bretto
|
|
|
|
|
|
Hi all. I've got a web applicaiton here that I'm developing against IE6 (it's for a company intranet, and they're still all on IE6...) The bug I'm noticing is this - If I select any single-line text box, and enter enough text so that the length of the text exceeds the length of the text box, the textbox pushes over to the left when I tab away from the textbox, or click away from it. The funny thing is that it's not resizing or anything to display the text therein, instead it's pushing over to the left by the distance that the text exceeds its length, staying the same sixe, and the text in the textbox remains shoved over to the left in the textbox, so that the last character is visible but the first one is not. Has anybody else come across this?
|
|
|
|
|
Hello all,
I am getting the following error:
The connection name 'MyConnection' was not found in the applications configuration or the connection string is empty. Although I have specified the connection string properly in my web.config file.
It was working earlier. What might be the problem?
Thanks.
|
|
|
|
|
hi,
i would like to know that how mono project is used?
i already made a application in asp.net using c#.
it will convert into mono or mono can change this
I will do my best?
Integrated Solutions, Bikaner (Raj.), India
|
|
|
|
|
|
hello
I too need to deploy a asp.net based web application in a linux based server
I have seen mono -project
Caio Kinzel Filho wrote: go to the mono site and download MoMA.
I have downloaded it but got few errors , It is critical to remove those errors
I also came to know regarding grasshopper.
If anyone knows how to deploy the project into a linux based server then please do let me know
Thanks and Regards
If You win You need not Explain............
But If You Loose You Should not be there to Explain......
|
|
|
|
|
hi
i've got a gridview on a parent webform. after closing a child form that was opened in modal mode i want the gridview to be refreshed. now i have tried several things that dont work and i dont know why:
1. tried to use: __doPostBack(buttonName,'') in javascript methode but nothing happened.
this is the code i have used:
code behind:
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack)
return;
btnNewChore.OnClientClick = "javascript:OpenChild( theURLOfTheChildForm, btnRefresh.ID)";
}
protected void btnRefresh_Click(object sender, EventArgs e)
{
gridViewChores.DataBind();
}
Javascript:
function OpenChild(theURLOfTheChildForm,targetButton)
{
var winSettings = "center:yes;resizable:no;dialogHeight:300px"
var returnValue = window.showModalDialog(URL, "", winSettings );
if (returnValue == null)
{
window.alert("NO chore was created!");
}
else
{
__doPostBack(btnName,'');
}
2.i've also tried to use
document.all("btnRefresh").click();
instead of __doPostBack but i've got an error :document.all("... not an object etc...
Thank you in advance for your help
yohay
modified on Monday, September 22, 2008 9:12 AM
|
|
|
|
|
I had this same problem. I never found a solution, I ended up using window.redirect('samePage.aspx');
I had used the code in the modal window to save the parameters in session state. Then when the parent page reloaded it used the new parameters to bind the grid.
I didn't get any requirements for the signature
|
|
|
|
|
Is the other page that's being opened an aspx page? If it is, you can try declaring an object type of formview in the popups code behind. For ex. FormView fv = new FormView();
fv = (FormView)this.Parent.FindControl("NameOfFormView");
fv.DataBind();
However, I used AJAX's modalpopupextender on an ascx User Control that was on my page, so I hope it will work for you too.
There is a possibility Parent may need to be in there more than once depending upon the levels.
|
|
|
|
|
Hi All,
I need to read image from the bitmap. I don't want to save it on to the server, but read directly from object in order to display it in image object . My code is:
HttpWebResponse response = request.GetResponse() as HttpWebResponse;
Stream stream = response.GetResponseStream();
MemoryStream ms = new MemoryStream();
BinaryWriter bw = new BinaryWriter(ms);
BinaryReader br = new BinaryReader(stream);
bw.Write(br.ReadBytes((int)response.ContentLength));
ms.Position = 0;
Bitmap fred = Bitmap.FromStream(ms) as Bitmap;
Now Please give me a solution to read the image from this bitmap.
D'kng
|
|
|
|
|
Are you making a windows application or a web application?
If you are making a windows application, you can just show the Bitmap in a picture box.
If you are making a web application, you are on the wrong track. To display the image in the browser you don't use a Bitmap object at all (unless you actually want to modify the image). What you read from the web request is an image file in form of a binary stream, and that is exactly what you send to the browser when it requests the image. However, you can't use the image stream in the same response as the page, you have to send it in a separate request. Make a separate page that gets the image and sends it as the response stream to the browser, and use that page as source in the image tag.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Hi Guffa,
Thanks for ur suggestion. I am using it on web application. I have written an HttpHander for the same, but it is not working on Firefox.Can u give me a quick solution.
Here is my handler.
public class FlyImage : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
System.Net.HttpWebRequest request = System.Net.WebRequest.Create("http://www.codeproject.com/SiteRes/CP/Img/Std/logo225x90.gif") as System.Net.HttpWebRequest;
context.Response.Clear();
context.Response.Expires = -1;
context.Response.ContentType = "image/gif";
context.Response.Cache.SetCacheability(HttpCacheability.NoCache);
byte[] img = null;
System.Net.HttpWebResponse response = request.GetResponse() as System.Net.HttpWebResponse;
System.IO.Stream stream = response.GetResponseStream();
System.IO.BinaryReader binaryReader = new System.IO.BinaryReader(stream);
img = binaryReader.ReadBytes((int)response.ContentLength);
context.Response.OutputStream.Write(img, 0, img.Length);
}
public bool IsReusable
{
get
{
return false;
}
}
}
DK
|
|
|
|
|
d'kng wrote: but it is not working on Firefox
The code doesn't run in the browser, it runs on the server, so it's not really browser specific in any way. What specifically do you mean by "not working"?
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Hi Guffa,
Now it is working fine. The code was OK but the only problem was due to my Default page. As when I changed my page name, it started working fine. Initially it was asking to download my Default.aspx Page. I don't know the reason but now it is working fine.
Many Thanks....DK
|
|
|
|