|
I've got an ASP .NET webpage with the following structure:
<asp:DataGrid ID="aGrid">
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<asp:Repeater ID="aRepeater">
<HeaderTemplate>
<asp:Label ID="aLabel" Text='<%# DataBinder.Eval(Container.DataItem, "SomeColumn") %>'></asp:Label>
</HeaderTemplate>
<ItemTemplate>
<asp:TextBox ID="aTextBox" AutoPostBack="true" OnTextChanged="SomeEvent"></asp:TextBox>
</ItemTemplate>
</asp:Repeater>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>
The problem I'm having is that I would like to access the data that is stored in the label aLabel in the OnTextChanged event. What I'm doing to achieve this purpose is:
void SomeEvent(object sender, EventArgs e)
{
Repeater r = (sender as TextBox).Parent.Parent;
}
My assertion, however, fails, and even if I get aLabel.Text , it ends up being an empty string, since r.DataSource is null (despite the fact that in the ItemDataBound event of aGrid, I already bound the repeater to a data source). After some debugging, I noticed that Repeater r is not the same repeater as the one that I bound in the ItemDataBound event of aGrid, but how could that be? In the ItemDataBound event of aGrid, I do the following...
<br />
e.Item.FindControl("aRepeater") as Repeater;<br />
...which I assume should be equivalent to...
(sender as TextBox).Parent.Parent;
Sorry for the long post.
|
|
|
|
|
I hired a coder to take my access db to mssql db with asp.net forms. He is no longer in the
picture and I am getting errors when one of my forms generates an email.
I think I have isolated the part of the code with the problem, but please answer as if I am an idiot,
because in this area, I am. TIA
I get this error: Unable to read data from the transport connection: net_io_connectionclosed
Protected Sub Page_Unload(ByVal sender As Object, ByVal e As System.EventArgs) If Me.ChangedLabel.Text = "Yes" Then Dim mailer As System.Net.Mail.SmtpClient = New System.Net.Mail.SmtpClient() If debug = False Then mailer.Send("registration@lmhsc.org", "EnrolleeUpdates@lmhsc.org", _ HttpContext.Current.User.Identity.Name &amp; ": this user has made changes to class registration for the " &amp; SessionNameLabel.Text &amp; " session.", _ "The above user has just registered for a new class. The " &amp; Me.FamLastNameLabel.Text &amp; " family has changed " &amp; numadded &amp; " student record(s).") Else mailer.Send("registration@lmhsc.org", "EnrolleeUpdates@lmhsc.org", _ HttpContext.Current.User.Identity.Name &amp; ": this user has made changes to class registration for the " &amp; SessionNameLabel.Text &amp; " session.", _ "The above user has just registered for a new class. The " &amp; Me.FamLastNameLabel.Text &amp; " family has changed " &amp; numadded &amp; " student record(s).") End If End If
--------------------------------------------------------------------------------
|
|
|
|
|
I'm afraid that hiring people via rentacoder almost always ends this way.
bjh29 wrote:
Protected Sub Page_Unload(ByVal sender As Object, ByVal e As System.EventArgs)
If Me.ChangedLabel.Text = "Yes" Then
Dim mailer As System.Net.Mail.SmtpClient = New System.Net.Mail.SmtpClient()
If debug = False Then mailer.Send("registration@lmhsc.org", "EnrolleeUpdates@lmhsc.org", _ HttpContext.Current.User.Identity.Name & ": this user has made changes to class registration for the " & SessionNameLabel.Text & " session.", _ "The above user has just registered for a new class. The " & Me.FamLastNameLabel.Text & " family has changed " & numadded & " student record(s).") Else mailer.Send("registration@lmhsc.org", "EnrolleeUpdates@lmhsc.org", _ HttpContext.Current.User.Identity.Name & ": this user has made changes to class registration for the " & SessionNameLabel.Text & " session.", _ "The above user has just registered for a new class. The " & Me.FamLastNameLabel.Text & " family has changed " & numadded & " student record(s).")
End If End If
Sending an email in the page unload seems a bit odd to me. I mean, I am not even sure what the control state would be at this point.
1 - You have a control called ChangedLabel and the text needs to be Yes, in that casing, yes and YES will fail. Is this right ?
2 - you have a debug flag in the program, if it's set to true, then the mail won't send.
3 - I don't see any code that sets up the mail server, so I don't think this code would work.
4 - the email addresses are all hard coded, as is the message, making it harder to change them later, this is an example of the terrible quality of work you get when you pay someone in India peanuts to do a job, especially if you're clueless about development, an Indian team needs a firm and experienced hand to keep them in line and make them deliver a decent product, or at least one that's in line with the spec. This is not because they are Indian, it's because they are remote, and usually under experienced. The same would happen if you were in New York and hired first year students in LA, which is, in essence what you probably ended up doing.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Let me clarify....I was very happy with the stateside coder. I released him from the project, thinking I had found the bugs. The project has been up and running for some time now.
In response to your list:
1. The users must click on a an agree button, so I believe this is the Yes...no option of yes or YES
2. so if I just make the debug to true, I can bypass the email sending until I figure this out?
3. The mail server set up is in my web.config file
4. The email being sent is notifying me when users enter info into my db, hence letting me know when I have accounts to process.
|
|
|
|
|
1 - sure seems strange to me, you're checking the text on a control, that seems a round about way to check if a button was checked.
2 - If you make debug true, then the email object is still created ( inefficient, but it won't break anything ) and the email just won't send. Isn't the email not sending your issue ?
3 - you can do that, and it automatically configures the server when you create the object ? OK, I didn't know that
4 - If I were you, I would set up a table in the DB that does this, you could still send an email, but then you can check the DB and it will tell you what users have entered data. I would always have a backup, in case an email is lost.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
I am sorry. I was not clear. It is generating emails, actually a LOT of them. It seems one is generated each time a text box updates.I get emails telling me 0 records are changed and one each time a record is changed. My problem is intermittent. About every 10 entries or so, I get the error. Perhaps if I could lesson the amount, it wouldn't error???? Could my mail server be overloading?
1. I could be wrong on what that is doing
2. What happens to the email created if it doesn't send?
3. OK
4. Hmm...will have to hire some help if I go that route.
Thanks
|
|
|
|
|
2 - there is no email sent if that setting is true. Only the object used to send mail is created
The place you're doing it is just silly. It is sent whenever the page unloads. The fact you get them when 0 records are changed, means the check if a controls text is Yes is not working. The code is either wrong, or the way it's being tracked, is a hack. The place to do this is an event handler for when the records are changed. If you send an email at all, it should be in the same code that saves a new record. Overall, I think you should be storing records in your DB to say that changes have occured, and perhaps have a windows service that once a day checks for rows that tell it updates occured, and send you one email to tell you a summary of changes for the day.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
That's above my head. I guess I will have to look at paying someone else to write some more code Since this is for a teeny non-profit, I may have to just turn off the email notice for now.
Thanks
|
|
|
|
|
bjh29 wrote: Page_Unload
This shows the person who wrote this code had no idea about how ASP.NET page life cycle works. Page_Unload will be called each time when the page refreshes and if I remember correctly, it is one of the events executed when page rendering completes. BTW, why you need and email from this event?
|
|
|
|
|
The form is for class registrations. I wanted to know when students were registered for classes. This for a homeschool co-op It is a three step process. 1. The family registers (I get an email for this, which for now is sufficient), 2. A volunteer is entered (a family member). 3. students are entered into classes - this is the process which gives me intermittent headaches.
This is what I had asked for, now in hindsight, I should have asked for a daily summary. Many of the things I asked for in the project were due to my inexperience in this realm.
|
|
|
|
|
Hi,
************************
Beginner Question *
************************
What is the best way to create Master page layout in VS2008.
-> Using drag n drop feature
-> Using CSS and hand coding for ...
-> Using free template off the NET.
OR ANY OTHER EASY WAY OUT...
If using drag n drop feature then how can i create a table, separating header, footer, left side container and main container ?
If using CSS then is there any best way to know the exact size and width of the division. I mean in CSS we need to specify width and height but how do i know what size would fit the best or may be i am missing some easy step here. Please do let me know..
or if using free template then where can i find the best professional free templates as after googlin it i can find all the funky type of templates but i need professional.
Any help would be greatly appreciated.
cheers mate
aNdy
|
|
|
|
|
Never use the drag and drop, always just hand code. Sometimes you need to do some trial and error, but you end up in control of what code you end up with.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Hello to everybody,
I have the following problem. How can I send a hyperlink e.g. www.qwertz.com&p1=ä (with German special character) to another site? It is important, that the ASP.Net site send the Query with special Character, because the other site understands utf8 (directly database call), and cannot convert html.encoding.
What can I do, I’ve try it with Response. Encoding = Encoding.UTF8, but when I look in liveHeader(Firefox) then the system send information in html encoding.
Who has a solution for this problem?
Thanks for any ideas.
|
|
|
|
|
|
I am curently working on asp.net application and her CMS system...
This is virtual directory of site:
application
and CMS have his own virtual directory here
application/admin
so my question is: can i access first application folders such as:
application/images
from CMS system which is located in virtual directory
application/admin
------------------------------------------------------------------------------------
I was trying this way:
Request.Files[0].SaveAs(Server.MapPath("../test.txt"))
But this way i should exit virtual directory and get error
"Cannot use a leading .. to exit above the top directory."
Any help or alternative solution appreciated! Thx in advance....
|
|
|
|
|
MapPath is assuming that you're starting at the top level, not at your current one. So, don't do the . thing, specify the full path.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
hello everybody..
i have to provide feature of live web conferencing in my website i have no idea how to implement will u all guide me..Thanks..
|
|
|
|
|
meghamaharshi wrote: i have no idea how to implement
You want to implement it ? or want to integrate with some third party Application.
|
|
|
|
|
Thanks for reply..
if we can implement then its good and if any open source available then thats better..
|
|
|
|
|
In my application I have a Gridview, with template columns having Textboxes inside.
On entering some values in the first textbox and press tab, focus goes to second textbox
again I enter some value and press tab.....It should get saved in database.
I am trying to implement this functionality.....please help me....
SAJAN A PILLAI
ASP.NET,C#.NET Programmer
BANGALORE
"Winners don't do different things. They do things differently. ...
|
|
|
|
|
If you want to do it tab navigation then you need an eventhandler which should be called when focus removed from the second textbox else you can use a button set it default focus and on enter save it.
Cheers!!
Brij
|
|
|
|
|
On tab out of second textbox, it should get saved to database. Any ideas to implement this will be appreciated.
Thanks in advance
SAJAN A PILLAI
ASP.NET,C#.NET Programmer
BANGALORE
"Winners don't do different things. They do things differently. ...
|
|
|
|
|
As I said earlier, use eventhandler that save it in DB
Cheers!!
Brij
|
|
|
|
|
hello all.
here, iam trying to download a file from an ftp folder into a clients machine.
the problem is,
i have written my code in say download.aspx.
now the file is getting downloaded to the client machine but the generated html source of the download .aspx is getting appended to the file. in this case we are getting 1117 bytes.
i have used the following code
string filename = "Chadwick2007.pdf";
Response.AddHeader("Content-Disposition", "attachment; filename=" + filename);
Response.ContentType = "application/octet-stream";
FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://127.0.0.1/ftpfolder/" + filename);
request.Method = WebRequestMethods.Ftp.DownloadFile;
request.UseBinary = true;
FtpWebResponse response = (FtpWebResponse)request.GetResponse();
Stream responseStream = response.GetResponseStream();
StreamReader sr = new StreamReader(responseStream);
int i;
while ((i = responseStream.ReadByte()) != -1)
{
Response.OutputStream.WriteByte(Convert.ToByte(i));
}
i can provide any additional information if required.
thank you.
|
|
|
|
|
hi guys,
any one got client side piece of code to logoff/shutdown a system through.
Muthu
|
|
|
|
|