ScriptCam Integration for .Net: ScriptCamForDotNet Repository

Hi all,

Recently I had to take pictures from web camera in my Asp.Net page. There’s a great flash-based plugin works with jQuery, named ScriptCam. So I been dealing integration of this to my Asp.Net page.

You can see my bio above, I hate (unnecessary) postbacks. So it all works on client, faster, then I store the binary data of captured image in my Session variable. Next page I show it on Page_Load event.

You can see the working example here,
Or you can download the project from here.

That’s my first repository, I hope it becomes helpful for some fellas.

T-SQL: Concatenate Multiple Rows of a Column into One Cell

Simple: You have a column and you want to take all rows as one cell. So that you can do searching, ordering, whatever you like.

Solution: Declare a variable, in this case VARCHAR or NVARCHAR, then SELECT the variable by equaling [itself] plus [column name] plus [your seperation char].

Here’s the code snippet:

DECLARE @concatenated NVARCHAR(1000)
SET @concatenated = ''
SELECT @concatenated = @concatenated + [NAME_COLUMN] + ',' FROM [USERS_TABLE] WHERE [ID_COLUMN] < 100
SELECT @concatenated

Asp.Net Server Side: How to get Iframe’s Parent Window Url?

In Asp.Net server sided button’s click event, I somehow needed to find parent window url of an iframe, which means the url you see in the address bar of your web browser.

Let’s think of 2 pages: Parent.aspx and Child.aspx. Child.aspx is loading to an iframe in Parent.aspx. If you have a button in Child.aspx, you will be getting “Child.aspx” result when you use Request.Url method in this button’s click event.

But you see “Parent.aspx” in the address bar, right? So how to get it?

Here you need to work with client side peacefully. Otherwise the server will keep giving you the same result.

First, place a button running at server, add a click event and a client-click event.

<asp:Button ID="btnFindParentUrl" runat="server" Text="Get Url!" OnClick="btnFindParentUrl_Click" OnClientClick="fillHidden();"></asp:Button>

Put a hidden textbox inside a div with style=”display: none;” (not Visible=”false” for button because if you do client can’t see and fill it):

<div style="display: none;">
    <asp:TextBox ID="txtHiddenUrlField" runat="server" BorderStyle="None" Font-Size="0px" ForeColor="#F6F6F6" Height="0px" Width="0px"></asp:TextBox>
</div>

Now place javascript code of fillHidden() function:

<script type="text/javascript">
    function fillHidden() {
        document.getElementById('<%= txtHiddenUrlField.ClientID %>').value = parent.document.location.href;
    };
</script>

That’s all you have to do at client side.
Let’s go to the server:

protected void btnFindParentUrl_Click(object sender, EventArgs e)
{
    string parentUrl = txtHiddenUrlField.Text;
}

This way, you should be getting parent url from button in an iframe.