|
You can also try following line for newline in richtextbox.
richTextBox1.Text = "Some text " + Environment.NewLine + "Again some text.";
HTH
Jinal Desai - LIVE
Experience is mother of sage....
|
|
|
|
|
To All,
How to use RenderControl() method with Ajax Controls?
Thanks and Regards..
|
|
|
|
|
RenderControl[^]
Sathesh.
Blessed is the season which engages the whole world in a conspiracy of love.
|
|
|
|
|
Hi
I want to open a audio file on linkbutton click event...i boud the file name on linkbutton when we press on the button i actally want to play that sound file.my linkbutton is in datagrid.and audio file is xyz.osf formate..
Please help me
|
|
|
|
|
Try little googling[^], you will find your answer.
HTH
Jinal Desai - LIVE
Experience is mother of sage....
|
|
|
|
|
Hi To All,
Can any body help me how to print a web page using ASP.NET?
Thanks and Regards...
|
|
|
|
|
|
Thanks a lot...It helps...!!!!
|
|
|
|
|
My Pleasure.
Jinal Desai - LIVE
Experience is mother of sage....
|
|
|
|
|
Hello there
I have been spending almost half-a-day to get this problem solved, but could not even find a single article that would help me. I wonder whether nobody else has faced this problem.
Okay, my webpage involves creating excel files. My download button has code like this
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.ContentType = "application/vnd.ms-excel";
HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=clientcopy.xlsx");
HttpContext.Current.Response.TransmitFile(Server.MapPath("App_data/" + Viewstate["FileName"]));
HttpContext.Current.Response.Flush();
HttpContext.Current.Response.Close();
HttpContext.Current.Response.End();
Alright. this works fine. The problem is, After downloading I want to make Viewstate["FileName"] to be null. But whatever I do, during the next post back after the filetransmit, the Viewstate["FileName"] still retains the old value and refuses to get updated to null. I tried writing the Viewstate["FileName"] = null; at every possible place in the above code - at the begining, in the middle and at the end after response.end(). BUT no way
Can someone help on how to modify the viewstate after a file transmit???
Note:
=====
My webpage has an update panel. Button "GO" displays a report in the update panel based on some selections outside the updatepanel. Button "ADD" keeps on adding the displayed reports to an excelfile until Button "download" is clicked and excelfile is downloaded. "GO" and "ADD" triggers partial postback and "download" triggers fullpostback.
thanks
Kit
|
|
|
|
|
You may want to read this msdn[^] article about view states.
You may have to override the SaveViewState() method on the page and set the value to null. Don't forget to call the base.SaveViewState() through!
|
|
|
|
|
Try this
HttpContext.Current.Response.TransmitFile(Server.MapPath("App_data/" + Viewstate["FileName"]));
Viewstate["FileName"] = "";
HttpContext.Current.Response.Flush();
|
|
|
|
|
ViewState is the state of the "View", or in other words the state of the page displayed in the browser. Since the transmission of the file doesn't change that view it wouldn't change the ViewState. If you want something that can be changed with the file transmission you need to use a data location that can be affected by it. I suggest setting a cookie.
|
|
|
|
|
Thanks for the replies, guys.
@Yusuf: The link seems to be really good and informative. will go thro it. thanks. As a quick try, I tried overriding the SaveViewstate function. But that didnt help.
@Prosanta: It didnt work either. As I mentioned earlier I had placed the code at every possible location
@Gray: I think i will try storing it in the session. What say?
Cheers
Kit
|
|
|
|
|
Hi To All,
Can anybody help me how to print the selected tab in the Ajax tab container in HTML format?
On Button click I have to print the selected tab in HTML format.
So I have written one method for that.
public void RenderControl(Control ctrl)
{
StringWriter tw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(tw);
ctrl.RenderControl(hw);
String sb = tw.ToString();
Response.Write(sb);
Response.End();
}
protected void Button2_Click(object sender, EventArgs e)
{
TabPanel tbPnl = TabContainer1.ActiveTab;
RenderControl(tbPnl);
}
But I got the bellow mentioned exception when I click on the button in the application.
Script control 'TabPanel2' is not a registered script control. Script controls must be registered using RegisterScriptControl() before calling RegisterScriptDescriptors().
Parameter name: scriptControl
Any Help regarding this will be greatly appreciated..
Thanks in Advance...
|
|
|
|
|
From following code you will get particular TabPanel. So you
need to check properties of tab panel to get HTML.
Then you can print easily.
AjaxControlToolkit.TabContainer container = (AjaxControlToolkit.TabContainer)TabContainer1;
foreach (object obj in container.Controls)
{
if (obj is AjaxControlToolkit.TabPanel)
{
AjaxControlToolkit.TabPanel tabPanel = (AjaxControlToolkit.TabPanel)obj;
}
}
HTH
Jinal Desai - LIVE
Experience is mother of sage....
|
|
|
|
|
Dear Gentlemen,
I want to connect to GDS(Global Distribution System) for hotel booking in my website.. how can i go for it.. could you pls let me know about it. I tried in google but unfortunately i couldnt get proper resources.
please provide some links about this
Ahamed Azeem
Technical Lead
|
|
|
|
|
Find following link useful for the same.
GDS Integration[^]
HTH
Jinal Desai - LIVE
Experience is mother of sage....
|
|
|
|
|
I have a gridview control in aspx page. Suppose I have 3 columns, I need to have different colors for each column. I want to set different colors for three different columns in the gridview. Is it possible to set the colors in aspx page.
I have tried implementing, but could find any solution.
Please suggest me a way to achieve this...
CodingRocks
ASP.NET,C#.NET Programmer
BANGALORE
"Winners don't do different things. They do things differently. ...
|
|
|
|
|
Set ItemStyle-BackColor property of BoundField
<asp:BoundField ItemStyle-BackColor="Yellow" ....
|
|
|
|
|
You can also change color of particular row or column at
run time based on some condition.
i.e.
if(SomeCondition)
{
datagridview1.Columns[0].DefaultCellStyle.BackColor = Color.Aqua
datagridview1.rows[3].DefaultCellStyle.BackColor = Color.Aqua
}
else
{
datagridview1.Columns[0].DefaultCellStyle.BackColor = Color.Blue
datagridview1.rows[3].DefaultCellStyle.BackColor = Color.Blue
}
HTH
Jinal Desai - LIVE
Experience is mother of sage....
|
|
|
|
|
I have an ASMX webservice hosted alongside my ASP.NET web app. It is in the same project, hosted as the same IIS web application, and compiles to the same DLL. Now, I need to get the users session into the Webservice. To test this I made this simple method:
[WebMethod(EnableSession = true)]
public string checkSession()
{
return HttpContext.Current.Session["userid"].ToString();
}
So, first I login to my web app, then in the browser goto my webservice and click "checkSession" on that auto generated test page. I have tested this on 3 computers. All 3 of those work fine with the webapp(so the sessions are being created etc), and 2 of those return the value of Session["userid"] on invoking the webmethod, however the last computer returns "Object reference not set to an instance of an object" because Session is null.
So, whats the difference between these computers and why can my ASP.NET app get the sessions on all computers but the webservice cant?
I have also tested with my cellphone and it works there too.
Thanks
Strive to be humble enough to take advice, and confident enough to do something about it.
|
|
|
|
|
Well, See this msdn[^] article about sharing your session state between asp.net and web services.
|
|
|
|
|
I have looked through that article, and have done everything up to the point about cookie containers.
My webservice proxy has no such object, what am I missing?
EDIT:
Ok so I found that theres and attribute in the config file to enable the cookie container. But now my silverlight(which is what I am using to connect to the webservice) now gives this error:
"CookieContainer is not supported when using a browser-based HTTP stack. Cookies will be automatically managed by the browser. To gain manual control over cookies, switch to a different HTTP stack, for example by using WebRequest.RegisterPrefix with WebRequestCreator.ClientHttp."
But I don't think this has to do with Silverlight at all, or the cookiecontainer, because even that auto generated test page for the ASMX doesn't work.
Strive to be humble enough to take advice, and confident enough to do something about it.
modified on Wednesday, July 21, 2010 4:45 PM
|
|
|
|
|
Hi,
I am having problem in displaying report in doc file. the code is
SqlConnection cnx = new SqlConnection(categories.strCnx);
cnx.Open();
string query = @"select * from categories";
SqlCommand cmd = cnx.CreateCommand();
cmd.CommandText = query;
SqlDataReader dr;
HttpContext.Current.Response.Clear(); //clear anything in io buffer
HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=categories.doc");
HttpContext.Current.Response.Charset = "";
HttpContext.Current.Response.ContentType = "application/vnd.ms-document";
HttpContext.Current.Response.Write("categories" + '\n');
try
{
i = 0;
dr = cmd.ExecuteReader();
while (dr.Read())
{
s[i]= dr[0].tostring();
i++;
}
for (int j = 0; j
{
HttpContext.Current.Response.Write(s[j].ToString() + '\n');
}
HttpContext.Current.Response.End();
}
catch(Exception ex)
{
string pt = ex.ToString();
}
In this code, if I write the file inside the while(dr.read()), it works fine but when i tried to write it inside the for loop, it doesn't give the output.
Why is that and how to solve it ?? Any idea ??
sm
|
|
|
|