|
Hi,
CHeck the below code...
Response.Clear()<br />
Response.Charset = ""<br />
'set the response mime type for excel<br />
Response.ContentType = "application/vnd.ms-excel"<br />
Response.Charset = "iso-8859-1"<br />
'create a string writer<br />
Dim stringWrite As New System.IO.StringWriter<br />
'create an htmltextwriter which uses the stringwriter<br />
Dim htmlWrite As New System.Web.UI.HtmlTextWriter(stringWrite)<br />
dg.DataSource = ds<br />
'bind the datagrid<br />
dg.DataBind()<br />
'tell the datagrid to render itself to our htmltextwriter<br />
dg.RenderControl(htmlWrite)<br />
Dim strStyle As String = "<style>.text { mso-number-format:\@; } </style>"<br />
Response.Write(strStyle + stringWrite.ToString)<br />
Response.AddHeader("Content-Disposition", "attachment")<br />
Response.End()<br />
<br />
<br />
<br />
<br />
Protected Sub dg_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles dg.RowDataBound<br />
If e.Row.RowType = DataControlRowType.DataRow Then<br />
e.Row.Cells(1).Attributes.Add("class", "text")<br />
End If<br />
End Sub<br />
and just change the code in response.write line according to above...
Cheers
S Kumar
modified on Thursday, July 9, 2009 4:35 AM
|
|
|
|
|
Thanks a lot Kumar. It worked like a magic Thanks once again.
Hammad
|
|
|
|
|
Hi in my aspx page i have used ajax controls...,
in another page using request.forms i am getting the values of the prev page using post method...,
and inserting in to database...,
but the values are inserting 2 times...,
i dont y its happening...,
plz clear my doubt reg this....,
Thanks & Regards,
Member 3879881,
please don't forget to vote on the post
|
|
|
|
|
Member 3879881 wrote: i have used ajax controls...,
Which control are you using ?
Member 3879881 wrote: but the values are inserting 2 times...,
Show us the code? I guess it may be problem related with Postback !
|
|
|
|
|
Hi abhijit,
Thanks for ur reply...,
i have solved the probs...,
actually i given two times submit action thats y its happend...,
once again tks for ur reply
Thanks & Regards,
Member 3879881,
please don't forget to vote on the post
|
|
|
|
|
Member 3879881 wrote: actually i given two times submit action thats y its happend...,
|
|
|
|
|
hi sir,
i have a problem please solve this.
actually i have a gridview and in gridview i have column and column contain linkbutton now i want to add another linkbutton in that column in place of first linkbutton means first linkbutton will not display and this new linkbutton will display
|
|
|
|
|
vikas shukla wrote: actually i have a gridview and in gridview i have column and column contain linkbutton now i want to add another linkbutton in that column in place of first linkbutton means first linkbutton will not display and this new linkbutton will display
Then what is the use of First link button. or you want some visible true false kind of things !
|
|
|
|
|
Hi friends
I have a doc file in my project folder. I want the user to download the doc file for their reference. In that case, I used <a> tag
<a href="sample.doc" >download the sample doc</a>
The file opens well in IE in a write mode so that user can edit and save the file in his system memory. When I open the file using firefox, it opens in a read only mode so I m unable to modify/edit the file. I can modify it only after saving the file in my system memory...
I need to open the file in a write mode in firefox browser while open action without saving.
Could u help me how to solve this issue
Advance thanks.
G Nathan
|
|
|
|
|
|
would someone be kind enough to shed me some light on the following concepts? these aren't assignment or exam questions, just things i couldn't find in the book i am reading and unbingable.
* how would forms authentication be made to work if cookies aren't enabled?
* session state can be stored in a cookie or within a munged url. if latter, then for a 'busy' website, there would be a higher likelyhood that a naughty user can replace the session state portion of the url with some random value and 'steal' someone else's session?
* once a user has been authenticated (either via forms or windows), can session state be used from then onwards as a mechanism to identify if a user is who he says he is? at least until the session expires (is made to expire) and then the user has to login again?
* as I understand it, IIS and ASP.Net are both services running in a web server OS. As such they need a logon account to run as. For IIS it is IUSR_[ComputerName] while for ASP.NET (IIS7) it is 'whomever' is entered in the sites application pool. If impersonation is enabled, then it uses the said account to run the .Net codes behind the page. is this correct?
* where do I find it in MMC where to set the account to run IIS under? I couldn't even find the entry for the IIS service in administrative tools, services
muchos gracias
----------------------------------------------------------
Lorem ipsum dolor sit amet.
|
|
|
|
|
I have a web application developed in Visual Studio 2008 with Crystal Reports 2008. When I run it locally everything works fine. However, on the server I get the following error...
Webpage error details
User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; SLCC1; .NET CLR 2.0.50727; InfoPath.2; .NET CLR 3.5.30729; .NET CLR 3.0.30729)
Timestamp: Wed, 8 Jul 2009 17:13:38 UTC
Message: 'bobj' is undefined
Line: 62
Char: 3
Code: 0
URI: http://10.255.14.20/CustInfo/(X(1)S(xymqr1z51hhhyo55gpvftk55))/Pages/LookUpPages/DisplayCompany.aspx
Message: 'bobj' is undefined
Line: 71
Char: 24
Code: 0
URI: http://10.255.14.20/CustInfo/(X(1)S(xymqr1z51hhhyo55gpvftk55))/Pages/LookUpPages/DisplayCompany.aspx
I created the crystalreportviewers12 virtual directory in the IIS and I still get the same error.
Any ideas?
Bill
|
|
|
|
|
Never mind all. It's working now.
|
|
|
|
|
One Request. Please provide the solution over here. So that, if some on face the same problem can resolved quickly.
|
|
|
|
|
|
Hi all,
I have a composite ASP.NET server control includes a HTML button that shows a div which allows searching capacities, the Search capacities are implimented using AJAX, im inheriting from WebControl and impliementing INamingContainer and ICallbackEventHandler.
The Control that works fine if you have just one control on the an ASP.NET page.
If you add further controls onto the page the first control still works fully but all contols after that allow the show/hide behaviour but the Ajax bits dont work. There are no errors, the data area just stays blank.
I think i have a problem with the way im registering the callback function. this is the code im using which is in the overridded OnPreRender Method of the Server Control.
string sref = Page.ClientScript.GetCallbackEventReference(this, "arg", "display","", true);
string Callback = "function GetData(arg, context){" + sref + ";}";
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "CallBack", Callback, true);
This outputs the following section of html
<script type="text/javascript">
function GetData(arg, context){WebForm_DoCallback('LookupBox23123',arg,display,"",null,true);}
</script>
As you can see the first parameter of the callback contains the ID of the first control added (I know the ID is abit weird). I Think that is why the first control continues to work with Ajax but the rest don't.
Is there a way i can pass in the control name to the callback method so i can use multiple controls, or can i amend the script Reference to allow this functionality.
Many thanks Phil
|
|
|
|
|
Please ignore this now i've worked it out, although if anyone has a better way let me know.
I've used the context to pass the control name through.
string sref = Page.ClientScript.GetCallbackEventReference("context", "arg", "display","context","display_Error", true);
string Callback = "function GetData(arg, context){" + sref + ";}";
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "CallBack", Callback, true);
this means that in my javascript i've got calls like
GetData(Value,"Lookup1");
Cheers Phil
|
|
|
|
|
Greetings,
I would like to know if anyone has any code ASP.NET or even VB script, Perl etc that can simply be run from a command line to download whatever page is on a browser and write the raw HTML to a file, it can also be MHT for that matter.
I know about using - Navigate etc for a specific web page. This is different. The page I go to require authentication with word art and user name and password etc. Then once there you must click a few times to get where you are going for the data. Therefore running a script to direct me to a certain webpage will not work. The page has to be displayed first and then downloaded.
So, I just want to take whatever is currently on the browser, mainly due to catch refreshes of new data. Understand the page I am getting data from is generated as from a database so I can not simply run a script file to download that page. The program must be able to simple be activated and write to disk what ever is displayed on the browser at the time the program is run.
I have a seperate data extractor to run against the new file to find the data I need. This file can always have the same name as well and be overwritten.
Thanks,
Antone
|
|
|
|
|
This is considered as rude.
You already asked this question in C# forum.
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
modified on Wednesday, July 8, 2009 10:08 AM
|
|
|
|
|
Not clear why it is rude??? I am asking different forums and those that do not necessary see my question from other forums. So, if my question maybe answered in Perl and not in C# then the Perl guys will never see my question.
If this is not correct let me know. I have not been on here in many years.
Thanks,
Antone
|
|
|
|
|
Antone Eason wrote: Not clear why it is rude??? I am asking different forums and those that do not necessary see my question from other forums
Well, in such cases, you can post the question in most appropriate forum and link to it while posting in the other forums. Putting the same text in all places is considered to be rude.
To answer your question,
You have said the page you want to download requires authentication and some word art. Do you mean a CAPTCHA[^] ? If yes, getting the authentication pass is tough as you can't predict the value of CAPTCHA.
|
|
|
|
|
OK thanks I will look into linking for future posts. As far as my question I do not need to authenticate or worry about login credentials. I am already in fine, the page just changes every few minutes.
Think of it as simply being able to click the [view source] button on any web page that happens to be on the browser and then the source e.g. raw HTML is written to a text file.
That is what I need a script or program to be the view source button that I can invoke inside a batch file that is called by the scheduler every 5 minutes or so to check for the latest update.
Thanks,
Antone
|
|
|
|
|
Look at the WebClient class and work with DownloadString[^] method. It does exactly what you are looking for. Try to follow the below steps
1 - Create a console application which quits automatically once the job is done.
2 - Inside this, use WebClient class and request to the web page. This will give you raw HTML.
3 - Schedule this exe to run every 5 minutes for getting the latest updates.
Hope that helps
|
|
|
|
|
Hi - yes that sounds like an excellent solution. I will try just a little short on time.
Thanks again!
Antone
|
|
|
|
|
Hi - Yes that is security used. Thanks for your input and quick response.
Thanks,
Antone
|
|
|
|