|
try this
namespace MyProject.ViewManeger
{
///
/// Summary description for ViewManager
///
public class ViewManager
{
public static string RenderView(string path)//path of the user control
{
return RenderView(path, null);
}
public static string RenderView(string path, object data)
{
Page pageHolder = new Page();
UserControl viewControl = (UserControl)pageHolder.LoadControl(path);
if (data != null)
{
Type viewControlType = viewControl.GetType();
FieldInfo field = viewControlType.GetField("Data");
if (field != null)
{
field.SetValue(viewControl, data);
}
else
{
throw new Exception("View file: " + path + " does not have a public Data property");
}
}
pageHolder.Controls.Add(viewControl);
StringWriter output = new StringWriter();
HttpContext.Current.Server.Execute(pageHolder, output, false);
return output.ToString();
}
}
Rajeev Kr. Sharma
VRI Software Pvt.Ltd.
New Delhi India
HumOnline.com
Stay Connected
|
|
|
|
|
Thanks for replying Rajeev.
But I am talking about Custom controls, but you are saying about User Controls.
Thanks
|
|
|
|
|
Could you not apply the code to custom controls instead?
We are not a Code Charity
|
|
|
|
|
My project runs like this, from page1 I would get the username entered into the textbox.. In page2, I'll be displaying the name of the user based from his username.. Page2 also includes some buttons (like frmPersonalInfo, frmMedicalHistory, etc) that when the user clicks, it will lead them to a more detailed information..
But for example, I have another page (page2.1) and I want to get some value from page2.. It doesn't display anything at all when I'm on page2.1
I'm using a database for data access..
The main purpose of the data access from one form to another is for me to be able to create sql queries..
Code:
Page1
string pcode = txtUser.Text.ToString();
Response.Redirect("frmPage2.aspx?PCode=" + pcode);
Page2
protected void frmPage2_Activate(object sender, EventArgs e)
{
string patientcode = Request.QueryString["PCode"].ToString();
}
protected void btnPersonalInfo_Click(object sender, EventArgs e)
{
Response.Redirect("frmPage2.1.aspx?Code=" + patientcode);
}
Page2.1
protected void frmPag2.1_Activate(object sender, EventArgs e)
{
string code = Request.QueryString["Code"].ToString();
lbl.Text = code;
}
The passing of value from page1 to page2 actually works...
In page2.1, I used a label for try purposes only (lbl).. I just wanted to know if I could display the data there.
But when I run the program, it doesn't display anything eventhough the visibility is set to true..
I'm thinking that maybe because the "patientcode" variable in page2 was initialized not as a global variable.. So, maybe that's why page2.1 displays a null value??
What can you suggest for solution?
Thank you!
|
|
|
|
|
you would be correct. it should have shown an error in your code trying to use patientcode.
BTW you do not need the .ToString() on any of those.
string pcode = txtUser.Text;
Request.QueryString["PCode"];
Request.QueryString["Code"];
its already a string
|
|
|
|
|
This is my 4th bloody day dealing with the insanely stupid installation of T-bloody-F-bloody-S server. After solving a zillion problems (nearly every time having to uninstall and restart ) I've come to this gem:
The identity of application pool 'TFS AppPool' is invalid, so the World Wide Web Publishing Service can not create a worker process to serve the application pool. Therefore, the application pool has been disabled.
I tried changing permissions, I tried creating new users, in the end, before posting this, I set the pool identity to be the domain admin, a no-no for sure but a test to see whether I'm losing it or the software being installed is completely cuckoo, and the beauty I've posted above this paragraph shows up.
Now.
Does anyone have a suggestion before [horror of horrors ]I start from scratch yet again?
"Every time Lotus Notes starts up, somewhere a puppy, a kitten, a lamb, and a baby seal are killed. Lotus Notes is a conspiracy by the forces of Satan to drive us over the brink into madness. The CRC-32 for each file in the installation includes the numbers 666." Gary Wheeler
"You're an idiot." John Simmons, THE Outlaw programmer
"I realised that all of my best anecdotes started with "So there we were, pissed". Pete O'Hanlon
|
|
|
|
|
Have you tried this, see toward the end of the thread.
Yusuf
|
|
|
|
|
Yeah, I did. Sadly, it didn't work.
I've started off again with a clean VM, and if this doesn't work, I've got my tech support friend coming over on Friday to get it working.
He's done it several times.
If this doesn't work, I'm taking up farming...
"Every time Lotus Notes starts up, somewhere a puppy, a kitten, a lamb, and a baby seal are killed. Lotus Notes is a conspiracy by the forces of Satan to drive us over the brink into madness. The CRC-32 for each file in the installation includes the numbers 666." Gary Wheeler
"You're an idiot." John Simmons, THE Outlaw programmer
"I realised that all of my best anecdotes started with "So there we were, pissed". Pete O'Hanlon
|
|
|
|
|
how can right vigener cipher code withe any language prgramer
|
|
|
|
|
what are you looking for? Vigenere Cipher code in any language? Here is in peril, will that help?
Yusuf
|
|
|
|
|
Hello
I try to send a mailmessage to this mail info@ihacademy.net
i did a form where i specify all the constant of the mail
and this is the code behinder.
"protected void Send_Email(Object Sender, EventArgs e)
{
System.Web.Mail.MailMessage mail = new System.Web.Mail.MailMessage();
mail.To = Request.Form["to"];
mail.From = Request.Form["from"];
if (Request.Form["format"].Equals("text"))
mail.BodyFormat = MailFormat.Text;
else
mail.BodyFormat = MailFormat.Html;
mail.Subject = Request.Form["subject"];
mail.Body = Request.Form["body"];
SmtpMail.Send(mail);
Response.Flush();
Message.Text = "Message Sent...<br><br>" +
"<a href="\"sendMail.aspx\"">Go Back</a>";
}"
I don't have an error but nothing happen and i don't receive any message in the mail.
Any advice or correction will be greatly appreciated
And thanks in advance
Assaf
modified on Tuesday, June 3, 2008 12:30 PM
|
|
|
|
|
If you are using .NET 2.0 you should use System.Net.Mail, but you never set the smtp server you were using, so the code had no idea where to send the message. SmtpMail.Servers.Add is close to what you need. I recomend System.Net.Mail it lets you create a smtp object and control things that way, but if you arent using .NET 2 you wont have it, we had problems with the SmtpMail class in .NET 1.1, sometimes it threw an exception about the server so we had to readd the server using a different method and then it would work.
|
|
|
|
|
Thanks
I use System.Net.Mail but it give many error on it i'll give my code
"System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
/* Step 2*/
message.To.Add("info@ihacademy.net");
message.From.Address = "assaf-hassan@hotmail.com";
message.Subject = "Email Subject";
/*Step 3*/
message.IsBodyHtml.Equals(true);
//message.BodyFormat = MailFormat.Html;
/*Step 4*/
message.Body = "this a test for the mailmessage";
/*Step 5*/
SmtpMail.Send(message);
Response.Write("Email Sent");"
the two error is:
1-Error1 Property or indexer 'System.Net.Mail.MailAddress.Address' cannot be assigned to -- it is read only
2-Error2 The name 'SmtpMail' does not exist in the current context
So any help i'll appreciated
Thanks in advance
Assaf
|
|
|
|
|
a search of msdn will reveal that the to and from address should be set in the constructor of the MailMessage object, and that SmtpMail is obsolete(complier warnings should tell you this if you read them) and that you have to create an SmtpClient object and use it instead of SmtpMail. the context help in VS should have lead you down that path as well. Sorry if i seem rude I dont mind helping but quite a few of the posts to these forums are of the "pls urgent send code" or from people who never look at the help or google searches and that gets old fast, combinded with a horrid day at work puts me in a not very good mood. I dont know what your complier warnings are set to but i recomend level 4 as it will usually give you some decent information.
|
|
|
|
|
Hello Frnd
do you want ur application to send mail?
if yes then
u need SMTP Service on ur Pc which is provided by the iis
you sould use these namespaces
using System.Web.Security;
using System.Net.Mail;
using System.Net.Mime;
and then you should create a object of System.Net.Mail.MailMessage
this will provide you all the function of the Mail MEssage and
you have to use
SmtpClient objName=new SmtpClient();
client.Credentials = new System.Net.NetworkCredential("your emailAddress", "your Passowrd");
client.Host = "host name ";
client.Port = port on which number;
client.EnableSsl = true;
should try this in youor code..
Do let me know if u have any problem or not
|
|
|
|
|
Hi,
I thnk what is missing is SmtpMail.SmtpServer = "192.167.0.25";, which you need to asssing before calling the Send method. Simple Mail Transfer Protocol (SMTP) server for delivery from a .NET Framework application.
Thx,
Gayani
|
|
|
|
|
Hey
I have a DetailsView pointing to a datasource (a LINQ data source) that returns a row from a table to be displayed in the details view.
This works correctly and displays each column for the row in the DetailsView. However I wish to hide some of the columns such
as UserId and Acount_Balance so I have created fields for the DetailsView and bound them to the correct columns.
However now I get a DetailsView containing all the columns plus the bound columns I have created. How do I stop
the details view displaying all the columns and only show the ones I want it to.
Here is the code used:
<asp:LinqDataSource ID="OrganisorDetails" runat="server" ContextTypeName="DataClassesDataContext"
TableName="aspnet_Organisors" EnableUpdate="true" OnSelecting="OrganisorDetails_Selecting">
</asp:LinqDataSource>
<asp:DetailsView ID="DetailsView1" runat="server" Height="50px" Width="125px"
CellPadding="4" ForeColor="#333333" GridLines="None"
AutoGenerateEditButton="True" DataSourceID="OrganisorDetails" DataKeyNames="UserId" >
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<CommandRowStyle BackColor="#E2DED6" Font-Bold="True" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<FieldHeaderStyle BackColor="#E9ECF1" Font-Bold="True" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#999999" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<Fields>
<asp:BoundField DataField="Address_Ln1" HeaderText="Address Line1" InsertVisible="false" ReadOnly="true" />
</Fields>
</asp:DetailsView>
Thanks
At university studying Software Engineering - if i say this line to girls i find they won't talk to me
Dan
|
|
|
|
|
Sorry - stupid question, I had the DetailsView autogenerating fields.
For any one who comes across this problem just go to DetailsView Tasks --> Edit Fields and unselect autogenerat fields.
At university studying Software Engineering - if i say this line to girls i find they won't talk to me
Dan
|
|
|
|
|
Hi, Everyone
I'm doing project for customer and we must finish a module test online (Level english ) as <a href="http://www.english-test.net/esl/learn/english/grammar/ii406/esl-test.php">http://www.english-test.net/esl/learn/english/grammar/ii406/esl-test.php</a>[<a href="http://www.english-test.net/esl/learn/english/grammar/ii406/esl-test.php" target="_blank" title="New Window">^</a>]and we not know how finish it. Pls help me.
Thanks
|
|
|
|
|
what has this got to do with asp.net??
We are not a Code Charity
|
|
|
|
|
is this a PHP page ?????
what do you want exactly (.Net Module ) ?????? ??? ?
|
|
|
|
|
yes, it is module write by ASP.NET based C#, Can you help me?
|
|
|
|
|
Vunt1510 wrote: and we not know how finish it. Pls help me.
Vunt1510 wrote: I'm doing project for customer
I'm sure there are plenty of people here you could subcontract to, if you're unable to do the task you have taken money for, and don't even know enough about your problem to explain it beyond 'we don't know how to finish it'.
But, of course, that you asked here when it's PHP means you probably don't even know what tools you're using.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi,
I would like your opinion about this? How do you rate it? Is it like a code generation tool?
Brendan
|
|
|
|
|
check this out for more information on it:
http://msdn.microsoft.com/en-us/library/bb264518.aspx
We are not a Code Charity
|
|
|
|