|
Hi, Im working with this method. The problem is that Im creating a new page and then try to assing the Header.Title but it will throw and exception of NullReferenceException.
public static string RenderControl(string controlName)
{
Page page = new Page();
page.Header.Title = "New Page";
page.Controls.Add(header);
UserControl userControl = (UserControl)page.LoadControl(controlName);
userControl.EnableViewState = false;
HtmlForm form = new HtmlForm();
form.Controls.Add(userControl);
page.Controls.Add(form);
StringWriter textWriter = new StringWriter();
HttpContext.Current.Server.Execute(page, textWriter, false);
return textWriter.ToString();
}
Same thing if I try to add
HtmlLink myCSS = new HtmlLink();
myCSS.Href = "~/somecss1.css";
myCSS.Attributes.Add("rel", "stylesheet");
myCSS.Attributes.Add("type", "text/css");
Page.Header.Controls.Add(myCSS);
I try to set a new header but It says
page.Header
(Gets the document header for the page if the head element is defined with a runat=server in the page declaration.
but when you see the new Page() constructor it says <No Parameters> Cant set the header with attr runat=server when initialize the page.
Regards
modified on Monday, July 18, 2011 6:52 PM
|
|
|
|
|
I haven't implemented it ever but I think issue is with your code try this way:
HtmlHead head = new HtmlHead("head")
HtmlTitle title = HtmlTitle()
title.Text = "New Page";
head.Controls.Add(title)
page.Controls.Add(header);
Parwej Ahamad
ahamad.parwej@gmail.com
|
|
|
|
|
Hi,
I tried with below code for export gridview to Excell and it is adding empty row for every record . Please suggest me better way to do this.
My Code:
--------------
response.Clear();
response.ClearContent();
response.Buffer = true;
response.ContentType = "application/vnd.ms-excel";
response.Charset = "";
//--code to display multiline value in same cell in excel-------------------
string header = @"
";
response.Write(header);
response.AddHeader("mso-data-placement", "same-cell");
response.AddHeader("content-disposition", new StringBuilder("attachment; filename=").Append(fileName).Append(".xls").ToString());
}
System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
gvControl.RenderControl(oHtmlTextWriter);
// response.Write(oStringWriter.ToString().Replace("bordercolor=\"white\"", String.Empty));
response.Write(Regex.Replace(oStringWriter.ToString().Replace("bordercolor=\"white\"", String.Empty).ToString(), @"(<a[^>]*>)|
()", " ", RegexOptions.IgnoreCase));
response.End();
---------------------------
Regards,
Vishnu.
|
|
|
|
|
Please Format your Code using "Pre" tag.
|
|
|
|
|
|
I have a basic login page. when a user is logged in, I want him to be redirected to a page with a success message and after 3 seconds, I want him to be redirected to my home page.
I know that I can use sleep time, but it's not recommended. So what's the best way to achieve it?
|
|
|
|
|
I think you can implement through refresh tag under head section:
You can use the META HTML tag to redirect the user. Below is an example:
<META HTTP-EQUIV="Refresh" CONTENT="10;URL=http://www.yourdomain.com/">
OR
Try with :
Response.AddHeader("REFRESH","10;URL=http://www.yourdomain.com");
Parwej Ahamad
ahamad.parwej@gmail.com
|
|
|
|
|
You can use Javascript if you want:
setTimeout( 'window.location = "default.aspx";', 3000 );
You can excute that script from anywhere even in your codebehind.
Hope that helps
|
|
|
|
|
Hi All,
Is there any reporting Service which provide run time design.
I am using Crystal report.
Ramkumar
("When you build bridges you can keep crossing them. ")
http://ramkumarishere.blogspot.com
|
|
|
|
|
What is a "run time design"?
|
|
|
|
|
Hi
I am creating an extranet site which will use windows-based-authentication (Digest Authentication; http://www.codeproject.com/KB/aspnet/ASPDOTNETauthentication.aspx).
My question is; when using WBA a windows login dialog is displayed for users to provide their credentials. Is there a way to use a web form for this without changing the authentication method? Ie: I would like windows to allow/deny access to the site but I want the user to enter their credentials into a nicely CSS formatted page rather than a nasty windows dialog!
Im very new to APS .NET and web design! Please speak slowly and simply; I wont be offended.
Thanks
|
|
|
|
|
Extranet site ... meaning it is hosted outside your corporate network. Right ?
I would think you would want to use Forms based authentication if it is a stand-alone website.
I am currently working on a website which will be using Forms based authentication and the ASP.NET membership provider. I am coding my own login pages and user maintenace pages for this application.
Things you might want to investigate.
AspNetSqlMembershipProvider
Membership.ValidateUser
Membership.GetUser
FormsAuthentication.RedirectFromLoginPage
Just some quick search terms for you to investigate.
I'll be glad to help you if this is the direction you want to go.
|
|
|
|
|
You cannot replace the default dialog with your own dialog (or webpage). But you can simulate this by using Forms Authentication, a custom login page and Active Directory API. You just have to authorize your users through the AD API.
|
|
|
|
|
Hi there. It might be possible that what I want to ask has already been discussed on another thread. Still I am not sure.
Here is the scenario:
Must develop a web application site in ASP.NET which deals with hotels. So: hotels will come to register on this site. When a hotel will register new rooms or some other action then the application will have to publish that action as a post on their Facebook account.
Q1: Who can tell me which are the steps to make it possible? I created an app for my website, also.
Q2: Can I test this on localhost? We have the domain but has yet no host.
|
|
|
|
|
This information is very cleverly hidden in what most developers call documentation.
http://developers.facebook.com/[^]
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
thanks I have read from there some pages ... still more explicit tutorial will be needed
|
|
|
|
|
Take one component at a time and work with that. Search for HowTo: on google for that particular component.
Try to implement it. Then when you have tried and get stuck, or have issues come back and ask specific questions. Now a specific question looks like this;
--------
I am trying to integrate [XYZ component] onto my page, however [this is hapening], and i get [this error] at [this line of code]; The code i am using is below;
[insert correctly formatted code snippet]
--------
|
|
|
|
|
All right guys...I am sorry if I disturb you.
I will try to explain again my scenario:
We are developing a website which deals with hotels. A hotel will come to create an account on our website. They will register, for example, new rooms. When that happens need to post on their page of Facebook a message.
First question: Is this possible? And how? I created from developer.facebook an app. Then how will the message me sent without having to press a button.(i am thinking for a webservice).
I will come on with other questions...
Thanks in advance, adrian
|
|
|
|
|
I want to insert row to table(which is asp.net control)
after first click, row was inserted to table(list3_table.Rows.Count == 1)
but after i click again, list3_table.Rows.Count is 0 (i am checking when page_load event)
why the list3_table can't save row?
and how can i solve this problem?
aspx
<asp:table id="list3_table" runat="server">
cs.
protected void Button1_Click(object sender, EventArgs e)
{
TableRow tr = new TableRow();
TableCell tc = new TableCell();
Literal gradeLister = new Literal();
gradeLister.Text = list1_drop.SelectedValue;
tc.Controls.Add(gradeLister);
tr.Controls.Add(tc);
list3_table.Controls.Add(tr);
}
hi
My english is a little.
anyway, nice to meet you~~
and give me your advice anytime~
|
|
|
|
|
Have you looked at using a Gridview control on your page ?
|
|
|
|
|
plzz tell me how to begin in serial communication using asp.net .... i have designed the platform but how to interface with gsm modem is a difficult task for me......
plzz help me out coz its a big one deal for me ......
thanks
regards
ajay
|
|
|
|
|
Check the first link here[^].
The best things in life are not things.
|
|
|
|
|
I have implemented Google Map in my asp.net website using .net framework 4.0.
Its working very well.
But the problem is that my web space doesn't support .net 4.0
So, i need to know how i can make this Google Map using .net framework 2.0
I tried many things but didn't succeeded
Please help me out of it!
Thanks
|
|
|
|
|
Google Maps is handled via JavaScript. This isn't dependent on the version of the .NET runtime, so you shouldn't need to change the mapping side. What you may need to change is your ASP.NET code if you are using .NET 3 or .NET 4 features, and there's nobody here who could help you with that without seeing your source code.
Change the project type to .NET 2 in your solution and recompile the application. See what defects this causes and fix as necessary.
In future, you might want to check such basic things as the target framework before commencing any work.
|
|
|
|
|
Hi all,
I have textbox with of email. It has two validation one is required and another is regularexpression.
Can i show different message for the both validation?
e.g
This is validation logic
[Required(ErrorMessage = "*")]
[DataType(DataType.EmailAddress)]
[RegularExpression("^[\\w-]+(\\.[\\w-]+)*@([a-z0-9-]+(\\.[a-z0-9-]+)*?\\.[a-z]{2,6}|(\\d{1,3}\\.){3}\\d{1,3})(:\\d{4})?$", ErrorMessage = "Email address should be in proper format (e.g. username@domain.com)")]
public String Email
{
get;
set;
}
Below is html
<div class="input_set">
<div class="editor-label">
@Html.LabelFor(model => model.Email)
</div>
<div class="editor-field">
@Html.TextBoxFor(model => model.Email)
<br />
@Html.ValidationMessageFor(model => model.Email)
</div>
</div>
Now i wnat to show @Html.ValidationMessageFor(model => model.Email) message in different location.
One person's data is another person's program.
--J.Walia
|
|
|
|