Monday, March 26, 2012
Tabs Control
I downloaded it but can seem to find the control, where is it located?
Please help!
Assistance would be great as this is very important.
Thursday, March 22, 2012
Tags vs. code-behind
I just wanted to know whether its better to use the asp tags (or drag
n drop) or write the actual code-behind for things like login, data
accesses etc. I guess its easier to use the tags but does it have any
disadvantages ?
Thanks !On Feb 27, 10:36 am, "Zeba" <coolz...@.gmail.comwrote:
Quote:
Originally Posted by
Hi guys..
>
I just wanted to know whether its better to use the asp tags (or drag
n drop) or write the actual code-behind for things like login, data
accesses etc. I guess its easier to use the tags but does it have any
disadvantages ?
>
Using code-behind you separate Business Logic and UI design
Using code-inline the script can be changed without re-deploying the
whole application.
http://www.eggheadcafe.com/articles/20030518.asp
Using code-inline the script can be changed without re-deploying the
Quote:
Originally Posted by
whole application.
Something that should be totally avoided in "true MVC" applications.
It's a bad practice.
Looking into the article, which reads "There are certain situations where a
purely inline - code implementation is justified"... I tend to disagree.
Also, the author does not give any concrete examply to substantiate the
statement.
In my view, inline code can be and must be totally avoided. The reason is
obvious - seggregation of the UI from the logic... the heart of MVC
pattern.
--
Happy Hacking,
Gaurav Vaish | www.mastergaurav.com
www.edujini-labs.com
http://eduzine.edujini-labs.com
-------------
"MasterGaurav (www.edujini-labs.com)" <gaurav.vaish.nospam@.nospam.gmail.com>
wrote in message news:esUtIHnWHHA.1180@.TK2MSFTNGP05.phx.gbl...
Quote:
Originally Posted by
Quote:
Originally Posted by
>Using code-inline the script can be changed without re-deploying the
>whole application.
>
Something that should be totally avoided in "true MVC" applications.
It's a bad practice.
I agree.
Quote:
Originally Posted by
In my view, inline code can be and must be totally avoided. The reason is
obvious - seggregation of the UI from the logic... the heart of MVC
pattern.
I would agree, apart from in one specific instance related to ASP.NET -
Global.asax, where there are sometimes justifications for in-line code...
Juan is a particular advocate of this, IIRC...
On Feb 27, 2:16 pm, "MasterGaurav \(www.edujini-labs.com\)"
<gaurav.vaish.nos...@.nospam.gmail.comwrote:
Quote:
Originally Posted by
It's a bad practice.
It depends on the need.
No disadvantage. MS is moving towards "code free" development.
You can expect to see a lot more of this in the future, so you may want to get into it now.
"Zeba" <coolzebs@.gmail.comwrote in message news:1172568997.043126.138660@.a75g2000cwd.googlegr oups.com...
Quote:
Originally Posted by
Hi guys..
>
I just wanted to know whether its better to use the asp tags (or drag
n drop) or write the actual code-behind for things like login, data
accesses etc. I guess its easier to use the tags but does it have any
disadvantages ?
>
Thanks !
>
The base argument is really:
Rapid Code Development VS Good Code Development.
Unless I'm whipping up a demo that needs to be done by yesterday,
I would avoid tags 99.9% of the time.
Rapid <Good most of the time.
Good development means it is maintainable (among other things), and the
<tagsapproach is cumbersome in that regard.
"Zeba" <coolzebs@.gmail.comwrote in message
news:1172568997.043126.138660@.a75g2000cwd.googlegr oups.com...
Quote:
Originally Posted by
Hi guys..
>
I just wanted to know whether its better to use the asp tags (or drag
n drop) or write the actual code-behind for things like login, data
accesses etc. I guess its easier to use the tags but does it have any
disadvantages ?
>
Thanks !
>
On Feb 27, 5:36 am, "Zeba" <coolz...@.gmail.comwrote:
Quote:
Originally Posted by
Hi guys..
>
I just wanted to know whether its better to use the asp tags (or drag
n drop) or write the actual code-behind for things like login, data
accesses etc. I guess its easier to use the tags but does it have any
disadvantages ?
>
Thanks !
I agree with the other posters wholeheartedly. The UI should most
definitely be separated from the business logic. In my personal
experience, even for fast demos, there's no *compelling* reason to
embed the source code right in the Web page. That assumes, of course,
that you're using Visual Studio or a similar editor that's capable of
handling code-behind files. The plumbing is all handled for you, and
the development experience is virtually seamless.
However, that's my *personal* experience, and your mileage may vary.
Another consideration is whether or not you want people to see your
intellectual property. If the source code is embedded right in the
pages, it's a lot harder to protect your source code from casual
viewing. With code-behind, you can compile the business logic into one
or more DLLs and avoid deploying the .VB & .resx files altogether;
that, coupled with a decent obfuscator, helps to protect your
intellectual property.
Mike
On Feb 27, 5:36 am, "Zeba" <coolz...@.gmail.comwrote:
Quote:
Originally Posted by
Hi guys..
>
I just wanted to know whether its better to use the asp tags (or drag
n drop) or write the actual code-behind for things like login, data
accesses etc. I guess its easier to use the tags but does it have any
disadvantages ?
>
Thanks !
I would *especially* use a code-behind for data access. You'd be
divulging details about how you connect to your data source. Big no
no.
Same goes for user authentication and authorization.
Call me paranoid. These days, a determined hacker WILL penetrate your
system if he chooses to do so, and if your code is sitting there with
the instructions for connecting to your database right in the Web
pages, you WILL live to regret it.
Be safe. Move the code into a codebehind file. Obfuscate the code
during the build. Then, prior to deployment, remove any and all source
code files (except the global.asax file). Be sure not to include any
sensitive instructions in the global.asax file. Security is
everything.
Mike
Tags vs. code-behind
I just wanted to know whether its better to use the asp tags (or drag
n drop) or write the actual code-behind for things like login, data
accesses etc. I guess its easier to use the tags but does it have any
di
Thanks !On Feb 27, 10:36 am, "Zeba" <
> Hi guys..
> I just wanted to know whether its better to use the asp tags (or drag
> n drop) or write the actual code-behind for things like login, data
> accesses etc. I guess its easier to use the tags but does it have any
> di
>
Using code-behind you separate Business Logic and UI design
Using code-inline the script can be changed without re-deploying the
whole application.
http://www.eggheadcafe.com/articles/20030518.asp
> Using code-inline the script can be changed without re-deploying the
> whole application.
Something that should be totally avoided in "true MVC" applications.
It's a bad practice.
Looking into the article, which reads "There are certain situations where a
purely inline - code implementation is justified"... I tend to disagree.
Also, the author does not give any concrete examply to substantiate the
statement.
In my view, inline code can be and must be totally avoided. The reason is
obvious - seggregation of the UI from the logic... the heart of MVC
pattern.
Happy Hacking,
Gaurav Vaish | www.mastergaurav.com
www.edujini-labs.com
http://eduzine.edujini-labs.com
---
"MasterGaurav (www.edujini-labs.com)" <gaurav.vaish.nospam@.nospam.gmail.com>
wrote in message news:esUtIHnWHHA.1180@.TK2MSFTNGP05.phx.gbl...
> Something that should be totally avoided in "true MVC" applications.
> It's a bad practice.
I agree.
> In my view, inline code can be and must be totally avoided. The reason is
> obvious - seggregation of the UI from the logic... the heart of MVC
> pattern.
I would agree, apart from in one specific instance related to ASP.NET -
Global.asax, where there are sometimes justifications for in-line code...
Juan is a particular advocate of this, IIRC...
On Feb 27, 2:16 pm, "MasterGaurav \(www.edujini-labs.com\)"
<gaurav.vaish.nos...@.nospam.gmail.com> wrote:
> It's a bad practice.
It depends on the need.
No di
You can expect to see a lot more of this in the future, so you may want to g
et into it now.
"Zeba" <
legroups.com...
> Hi guys..
> I just wanted to know whether its better to use the asp tags (or drag
> n drop) or write the actual code-behind for things like login, data
> accesses etc. I guess its easier to use the tags but does it have any
> di
> Thanks !
>
The base argument is really:
Rapid Code Development VS Good Code Development.
Unless I'm whipping up a demo that needs to be done by yesterday,
I would avoid tags 99.9% of the time.
Rapid <> Good most of the time.
Good development means it is maintainable (among other things), and the
<tags> approach is cumbersome in that regard.
"Zeba" <
news:1172568997.043126.138660@.a75g2000cwd.googlegroups.com...
> Hi guys..
> I just wanted to know whether its better to use the asp tags (or drag
> n drop) or write the actual code-behind for things like login, data
> accesses etc. I guess its easier to use the tags but does it have any
> di
> Thanks !
>
On Feb 27, 5:36 am, "Zeba" <
> Hi guys..
> I just wanted to know whether its better to use the asp tags (or drag
> n drop) or write the actual code-behind for things like login, data
> accesses etc. I guess its easier to use the tags but does it have any
> di
> Thanks !
I agree with the other posters wholeheartedly. The UI should most
definitely be separated from the business logic. In my personal
experience, even for fast demos, there's no *compelling* reason to
embed the source code right in the Web page. That assumes, of course,
that you're using Visual Studio or a similar editor that's capable of
handling code-behind files. The plumbing is all handled for you, and
the development experience is virtually seamless.
However, that's my *personal* experience, and your mileage may vary.
Another consideration is whether or not you want people to see your
intellectual property. If the source code is embedded right in the
pages, it's a lot harder to protect your source code from casual
viewing. With code-behind, you can compile the business logic into one
or more DLLs and avoid deploying the .VB & .resx files altogether;
that, coupled with a decent obfuscator, helps to protect your
intellectual property.
Mike
On Feb 27, 5:36 am, "Zeba" <
> Hi guys..
> I just wanted to know whether its better to use the asp tags (or drag
> n drop) or write the actual code-behind for things like login, data
> accesses etc. I guess its easier to use the tags but does it have any
> di
> Thanks !
I would *especially* use a code-behind for data access. You'd be
divulging details about how you connect to your data source. Big no
no.
Same goes for user authentication and authorization.
Call me paranoid. These days, a determined hacker WILL penetrate your
system if he chooses to do so, and if your code is sitting there with
the instructions for connecting to your database right in the Web
pages, you WILL live to regret it.
Be safe. Move the code into a codebehind file. Obfuscate the code
during the build. Then, prior to deployment, remove any and all source
code files (except the global.asax file). Be sure not to include any
sensitive instructions in the global.asax file. Security is
everything.
Mike
Tags inside value field of appsettings in web.config
it looks likes this
<configuration>
<appSettings>
<add key="MyXmlData" value="<data><type></type>......." />
</appSettings>
</configuration
but i get an error message
some one help meYou need to encode/escape the characters. You can do it manually if you
know all of the rules, but I wrote a little utility for myself that I
know will do it right. I guess I should post the full app at some point,
but the relevant method is:
public string Encode(string input)
{
StringBuilder output = new StringBuilder();
using (StringWriter stringWriter = new StringWriter(output,
CultureInfo.InvariantCulture))
{
XmlTextWriter xmlWriter = new XmlTextWriter(stringWriter);
xmlWriter.WriteStartElement("element");
xmlWriter.WriteAttributeString("attribute", input);
xmlWriter.WriteEndElement();
xmlWriter.Close();
}
return output.ToString();
}
Just create a simple WinForms app with a textbox to past a value into, a
button that runs the Encode method, and then a textbox for the output
(not label - you want to be able to select the output for copy/paste).
Joshua Flanagan
http://flimflan.com/blog
Tags inside value field of appsettings in web.config
it looks likes this
<configuration>
<appSettings>
<add key="MyXmlData" value="<data><type></type>......." />
</appSettings>
</configuration>
but i get an error message
some one help meYou need to encode/escape the characters. You can do it manually if you
know all of the rules, but I wrote a little utility for myself that I
know will do it right. I guess I should post the full app at some point,
but the relevant method is:
public string Encode(string input)
{
StringBuilder output = new StringBuilder();
using (StringWriter stringWriter = new StringWriter(output,
CultureInfo.InvariantCulture))
{
XmlTextWriter xmlWriter = new XmlTextWriter(stringWriter);
xmlWriter.WriteStartElement("element");
xmlWriter.WriteAttributeString("attribute", input);
xmlWriter.WriteEndElement();
xmlWriter.Close();
}
return output.ToString();
}
Just create a simple WinForms app with a textbox to past a value into, a
button that runs the Encode method, and then a textbox for the output
(not label - you want to be able to select the output for copy/paste).
Joshua Flanagan
http://flimflan.com/blog
taking a file stream and posting it to a web page
I am getting a stream that contains a PDF file and the task is to get that to a browser for the users. I was able to write code to do this with small files, but there are files so big that it can't be stored in the byte array. I wrote a loop to break down the byte array and it comes accross about the right file size, but Adobe Acrobat can't read it and says it's corrupt. I am thinking there must be a way to write the stream directly into the browser. Why do I need to build a byte array to do things like this (all the examples I find use a byte array)? Is there a way to take the stream and just run it directly into the browser?
Here is the code I have. Works as long as the file doesn't exceed the limits of the byte array:
ProtectedSub Page_Load(ByVal senderAsObject,ByVal eAs System.EventArgs)HandlesMe.Load
'This returns the stream fine:
Dim msAs Stream = Test3A()
'Show the file on the web page
Dim bytByteStream()AsByte
ms.Seek(0, SeekOrigin.Begin)
ReDim bytByteStream(CType(ms.Length,Integer) - 1)
ms.Read(bytByteStream, 0,CInt(ms.Length))
Dim countAsInteger = 0
While count < ms.Length
bytByteStream(count) = Convert.ToByte(ms.ReadByte())
'bytByteStream(count) = ms.ReadByte()
count += 1
EndWhile
Dim brAs BinaryReader =New BinaryReader(ms)
Response.AddHeader("Content-Type","application/pdf")
Response.AddHeader("Content-Disposition","inline;filename=def.pdf")
Response.BinaryWrite(bytByteStream)
EndSub
Here is the same code with the do loop to break it down (but returns a file to the browser that Adobe Acrobat can't read: PublicSub test3c(ByVal msAs Stream) 'Show the file on the web page Dim bytByteStream()AsByte Dim intByteIndexAsInteger Response.AddHeader("Content-Type","application/pdf") Response.AddHeader("Content-Disposition","inline;filename=def.pdf") IfCType(ms.Length,Integer) > 65000Then intByteIndex = 65000 Else intByteIndex =CType(ms.Length,Integer) EndIf ms.Seek(0, SeekOrigin.Begin) ReDim bytByteStream(intByteIndex - 1) 'ms.Read(bytByteStream, 0, CInt(ms.Length)) Dim countAsInteger = 0 Dim intPlaceAsInteger = 0 Dim intCyclesAsInteger = 0 While count < ms.Length bytByteStream(intPlace) = Convert.ToByte(ms.ReadByte()) count += 1 intPlace += 1 If intPlace = 65000Then Response.BinaryWrite(bytByteStream)'Writes to the browser intCycles += 1 'Increse the cycle meter IfCType(ms.Length,Integer) - (intCycles * 65000) > 65000Then ReDim bytByteStream(65000)'If we have more than 65K more to go, set up for next chunk Else ReDim bytByteStream(CType(ms.Length,Integer) - (intCycles * 65000))'If less than 65K, then put out whatever we have left EndIf intPlace = 0 'Reset the index placment counter EndIf EndWhile Response.BinaryWrite(bytByteStream)
EndSub
MemoryStream outputStream = ' Construct the stream here...
Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = "application/pdf"
Response.AppendHeader("content-disposition", "inline; filename=PDFFile.PDF")
Response.BinaryWrite(outputStream.ToArray())
outputStream.Close()
Response.End()
NC...
NC,
I see what you are going for and it would be great if it could be simple like what you are doing. However, I am getting a 'stream' from an API which I am passing to the procedure we are working on. Standard 'stream' does not have a "ToArray()" method. Is there a way to convert the stream to a memoryStream? Is there a way around this?
Schu
Try this then:
Dim ms As Stream = Test3A()
Dim outputStream As MemoryStream = CType(ms, MemoryStream)
' Rest of code...
NC...
I get the following error:
Unable to cast object of type 'EMC.Centera.BlobStreams.BlobReadStream' to type 'System.IO.MemoryStream'.
It allowed me to pull it out into a byte array as shown in my earlier code, any other ideas on what would work?
Schu
I have no idea what an 'EMC.Centera.BlobStreams.BlobReadStream' is. I tried the cast with a normal Stream object with no problem, so no, I have no idea.
Did you try:
Dim ms As MemoryStream = Test3A()
NC...
Yes, I know, that is from the API. They claim it is coming out as a simple stream (but obviously if it were we wouldn't have issues). I rewrote the code assumeing it was a memorystream and got the error:
Specified argument was out of the range of valid values.
Parameter name: offset
when I got to the "...(outputStream.ToArray()). Any thoughts?
I was looking through the documentation for this vendor code (sparse) and they mention that the stream is a "blobstream". then it says "that is what your VB code will use to Read - the Stream.Read method."
So, is there a way to convert a blob stream into a memorystream?
Schu
Well, since I have no access to the API that you are using, and all the references to "BlobStream" seem to be Java API related, who can tell? I'd request help from the vendor that created the API as I don't think that you will get much help here.
You know, if you could write the BlobStream thing to a temporary file, this would work:
Dim fileName As String = Server.MapPath("~\Reports\TestPdfFile.pdf")
Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = "application/pdf"
Response.WriteFile(fileName)
Response.Flush()
Response.Close()
NC...
Yea, that's a good idea too. Late last night I got together with a couple of the sr devs here and we came up with the following solution that seems to be working. I rem'd out the code that I had in the earlier post so you can see that all I did was remove a section. Thanks for your help! :)
'Show the file on the web pageDim bytByteStream()AsByte
'ms.Seek(0, SeekOrigin.Begin) ReDim bytByteStream(CType(ms.Length,Integer) - 1) ms.Read(bytByteStream, 0,CInt(ms.Length)) 'Dim count As Integer = 0 'While count < ms.Length ' '>>Following line produces error: ' ' "Value was either too large or too small for an unsigned byte." ' bytByteStream(count) = Convert.ToByte(ms.ReadByte()) ' '>>also tried this which did not work ' ' "Arithmetic operation resulted in an overflow." ' 'bytByteStream(count) = ms.ReadByte() ' count += 1 'End While Response.AddHeader("Content-Type","application/pdf") Response.AddHeader("Content-Disposition","inline;filename=def.pdf")Response.BinaryWrite(bytByteStream)
Well, I was wondering why you seemed to be filling the Byte array and then refilling it in the loop, but I guess I got side-tracked on the MemoryStream thing. Glad you got it.
NC...
Tuesday, March 13, 2012
Tapestry-like Page Framework?
Is there any tapestry-like page framework built on ASP.NET?
I want to be able to write simple page like this:
<html>
..
<body>
Hello, <span insert="User.Name">TestName</span>!
<table>
<tr iterateOver="ProductCollection" itemVariable="product">
<td insert="product.Name">TestProduct</td>
<td insert="product.Price">$1000</td>
<td><input type="checkbox" bind="product.Ordered"/></td>
</tr>
</table>
</body>
</html>
The UI controls are used implicitly, decided by their attributes rather
than the tag name, and their data binds to speficied objects directly
(i.e. there should be nothing like TextBox.Text). And web designers can
edit & preview the page in WYSIWYG editors without any problem, since
it's just plain HTML.Aquila Deus wrote:
> Hi all!
> Is there any tapestry-like page framework built on ASP.NET?
> I want to be able to write simple page like this:
>
Ummm I just make a more complete sample
http://www.aqd.ath.cx/code-public/sketch/Simple.html
I guess nobody is doing this for .NET... I'll probably need to write it
myself :)
Tapestry-like Page Framework?
Is there any tapestry-like page framework built on ASP.NET?
I want to be able to write simple page like this:
<html>
...
<body>
Hello, <span insert="User.Name">TestName</span>!
<table>
<tr iterateOver="ProductCollection" itemVariable="product">
<td insert="product.Name">TestProduct</td>
<td insert="product.Price">$1000</td>
<td><input type="checkbox" bind="product.Ordered"/></td>
</tr>
</table
</body>
</html
The UI controls are used implicitly, decided by their attributes rather
than the tag name, and their data binds to speficied objects directly
(i.e. there should be nothing like TextBox.Text). And web designers can
edit & preview the page in WYSIWYG editors without any problem, since
it's just plain HTML.Aquila Deus wrote:
> Hi all!
> Is there any tapestry-like page framework built on ASP.NET?
> I want to be able to write simple page like this:
Ummm I just make a more complete sample
http://www.aqd.ath.cx/code-public/sketch/Simple.html
I guess nobody is doing this for .NET... I'll probably need to write it
myself :)
targeting a response.write to a section of a web page
response.Write("<a href='www.yadda.com >Hello</a><br />")
multiple times, creating hyperlinks like so:
Hello
Hello
Hello
Hello
Hello
Hello
Anyway, I want the values above to be put in a specific location of my
web page (inside a table cell), instead of the top, which pushes all my
content down.
Basically, I am using xquery in a search field to go through an xml
document that contains my web site navigation info, returning a url
attribute. I have the url string from the xml doc converted to a
hyperlink using the code above.
Any suggestions are appreciated.Can you drop label members where you want the links and just add this
code to your method?
label.Text = "<a href='www.yadda.com'>Hello</a>";
Hope this helps.
I ended up hiding a table within the table and appended rows and cells
with the urls.
for each book in nodeList
Dim tempRow As New TableRow()
Dim tempCell As New TableCell()
tempCell.Text = "<a class='HoverStyle' href="http://links.10026.com/?link= &
book.Attributes("url").Value & " target='_blank' a>" &
book.Attributes("title").Value & "</a>"
tempRow.Cells.Add(tempCell)
tblSearchResults.Rows.Add(tempRow)
next
thanks.
simple solution...
1) Make the table Cell Server control . <td id="cell1" runat="server"
2) keep adding all links to the cell
cell1.InnerHtml += "<a href='www.yadda.com >Hello</a><br />"
better solution.. this way u will have better control on the layout of
links
1) Make the table a Server control . <table id="table1" runat="server"
2) keep adding rows HtmlTableRow and HtmlTableCell objects to the table
for each link
targeting a response.write to a section of a web page
response.Write("<a href='www.yadda.com >Hello</a><br />")
multiple times, creating hyperlinks like so:
Hello
Hello
Hello
Hello
Hello
Hello
Anyway, I want the values above to be put in a specific location of my
web page (inside a table cell), instead of the top, which pushes all my
content down.
Basically, I am using xquery in a search field to go through an xml
document that contains my web site navigation info, returning a url
attribute. I have the url string from the xml doc converted to a
hyperlink using the code above.
Any suggestions are appreciated.I ended up hiding a table within the table and appended rows and cells
with the urls.
for each book in nodeList
Dim tempRow As New TableRow()
Dim tempCell As New TableCell()
tempCell.Text = "<a class='HoverStyle' href="http://links.10026.com/?link= &
book.Attributes("url").Value & " target='_blank' a>" &
book.Attributes("title").Value & "</a>"
tempRow.Cells.Add(tempCell)
tblSearchResults.Rows.Add(tempRow)
next
thanks.
simple solution...
1) Make the table Cell Server control . <td id="cell1" runat="server"
2) keep adding all links to the cell
cell1.InnerHtml += "<a href='www.yadda.com >Hello</a><br />"
better solution.. this way u will have better control on the layout of
links
1) Make the table a Server control . <table id="table1" runat="server"
2) keep adding rows HtmlTableRow and HtmlTableCell objects to the table
for each link
TCP sockets
thank youTake a look at the System.Net.Sockets namespace, in particular TcpClient. There is a pretty good example in the documentation