|
Hi,
I have web page that has useful information on it but I don't want any user copy this information or add my logo if user copy this.please help me
|
|
|
|
|
You can't. You can make it complicated, but you cannot fully prevent a user from copying the contents.
|
|
|
|
|
So, how can I complicate it ? can I Add logo of my site in a back ground or some thing like this when they copy this data the logo appear on it?
|
|
|
|
|
It's impossible to prevent someone from taking a screenshot So if you embed your image as base64, split up the base64-string in variables and spread it around in a bunch of js-files, it's still easy to copy your logo.
--------------------
When Chuck Norris' dreams come true, your worst nightmares begin.
|
|
|
|
|
That's a good idea thanks but can you give me an example of it , write some code please
|
|
|
|
|
code to base64 encode and split it?
You can do it. I'll give you a few tips:
Online tool for converting images to base64 embedded image: http://webcodertools.com/imagetobase64converter/[^]
This will give you an img-tag ready to use.
Example (using jQuery):
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf89hAAAAB3RJTUUH2AQPB0tAAAAARnQU1" />
I removed most of the string for it to be easier to read. They are usually very long
Then you take the base64 value "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf89hAAAAB3RJTUUH2AQPB0tAAAAARnQU1", put it in a javascript variable (or multiple) like this:
var part1 = 'iVBORw0KGgoAAAANSUhEUgAAABAAAAA';
var part2 = 'QCAYAAAAf89hAAAA';
var part3 = 'B3RJTUUH2AQPB0';
var part4 = 'tAAAAARnQU1';
Remove the src-attribute value from your img-tag and give it an id-attribute
<img src="" id="myImg"/>
$(document).ready(function(){
var base64src = 'data:image/png;base64,' + part1 + part2 + part3 +part4;
$('#myImg').attr('src', base64src);
});
This will NOT prevent a user from copying your image! It's (as I said) easy to do a screenshot...
--------------------
When Chuck Norris' dreams come true, your worst nightmares begin.
|
|
|
|
|
I did it but it doesn't different between your code and add image as background , I want when user copy my text in a web page and paste it on word both text and logo paste
|
|
|
|
|
Isn't your question about preventing this?
--------------------
When Chuck Norris' dreams come true, your worst nightmares begin.
|
|
|
|
|
Did you mean, you want the users to avoid following things
1) Dont save your page
2) avoid right click and ctrl+c
|
|
|
|
|
yes exactly, or if user copy my page also my logo paste on it
|
|
|
|
|
You can't do this I'm afraid. If the user turns off JavaScript, your page is purely the content and the user can copy it as they like.
|
|
|
|
|
Hi! I am making an e-shop and i have a search function where you can search for a product in the website. So, it returns the products on the search result page. Then, i want to be able to add the product to cart from the result page. For some reason, the same code i use elsewhere is not working.. i am getting the "Index was out of range. Must be non-negative and less than the size of the collection." error.
Here is my code:
Protected Sub DataList1_ItemCommand(sender As Object, e As System.Web.UI.WebControls.DataListCommandEventArgs) Handles DataList1.ItemCommand
Dim currentCommand As String = e.CommandName
Dim currentRowIndex As Integer = Int32.Parse(e.Item.ItemIndex)
If currentCommand = "ProductID" Then
Session("Product") = DataList1.DataKeys(currentRowIndex)
Response.Redirect("Search.aspx", False)
ElseIf currentCommand = "AddtoCart" Then
Session("Product") = DataList1.DataKeys(currentRowIndex)
ShoppingCart.Instance.AddItem(Session("Product"))
Response.Redirect("ViewCart.aspx", False)
End If
End Sub
As you can see, i used the Label2 to check the value of the currentRowIndex. In the search i made i had 2 records, for the first one currentRowIndex=0 and for the second currentRowIndex=1.
What am i doing wrong?
|
|
|
|
|
That's pretty slick code there, and you even knew how to access data from the EventArgs. Strange if you know how to use the eventarg, that you didn't test the value of it e.Item.ItemIndex to make sure it's a value from 0 to the max value of int32.
I don't see the purpose of passing the session value to the shopping cart instance
Dim currentRowIndex As Integer = Convert.ToInt32(e.Item.ItemIndex)
Session("Product") = DataList1.DataKeys(currentRowIndex)
ShoppingCart.Instance.AddItem(DataList1.DataKeys(currentRowIndex))
|
|
|
|
|
Such an error can be thrown when you do DataList1.DataKeys(currentRowIndex) .
For debugging purposes, I'd add some lines after Dim currentRowIndex ... for checking that value:
If currentRowIndex<0 Then
ElseIf currentRowIndex>=DataList1.DataKeys.Count Then
EndIf
You should show the value of currentRowIndex and DataList1.DataKeys.Count in the error messages, and then do some further analysis based on those values.
|
|
|
|
|
I should of wrote
If Not currentRowIndex > Integer.MinValue And currentRowIndex < Integer.MaxValue Then
'Deal with the Error
Else
'now run the code
End If
|
|
|
|
|
Thank you so much guys! I solved the problem
Actually it was something stupid in the asp code.. i forgot to use DataKey field so, of course, DataList1.DataKeys.Count was always = 0 :P
|
|
|
|
|
Good to hear,
you should still improve the code you posted to better handle and invalid input, it will bite you back in the future,
In the future, you will start checking the error logs on your web server, and you will see all these errors, from input that was not validated. I see bots pick up trying to break a website all the time.
|
|
|
|
|
I added the code you suggested. But unfortunately i don't know a lot about security yet, for now i'm trying to fix the basics. I guess in 2-3 weeks you will see my posts here asking about security issues
|
|
|
|
|
I am getting the data from MySQL like this:
SELECT item_id, item_category, item_code, item_description, quantity_type_id, quantity_type, item_quantity as available_quantity, CONCAT(item_quantity, ' ', quantity_type) as item_instock, is_blocked FROM storebook_items ORDER BY item_description;
where item_quantity is int, quantity_type is varchar and item_instock a combination of both as you can see..
when I run the above on my database server as query then everything is fine
but when I populate the result to a datagrid (XtraGrid) I get System.Byte[] in the item_stock column.
|
|
|
|
|
|
Thanks
|
|
|
|
|
Hello.
I intend to bind my dropdownlist to sqlserver and read the items(CityName)that i have them in DB(Table City)and then list and fill them into the dropdownlist.
for this matter i have written the code below in Page_load that whenever i start to debug all city items to be seen in dropdownlist:
if (!IsPostBack)
{
using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["PersonTest"].ConnectionString))
{
conn.Open();
using (SqlCommand cmd = new SqlCommand("SELECT CityName , id FROM City", conn))
{
DataTable dt = new DataTable();
SqlDataAdapter adpt = new SqlDataAdapter(cmd);
adpt.Fill(dt);
DropCity.DataTextField = "CityName";
DropCity.DataValueField = "CityId";
}
}
}
but after i start to debug there is no item in dropdownlist.
meanwhile i know that i can use ASP.net DataBinding(by wizard)ability, but i want to do it with myself . and also i don't know which one is better to be used in forms? which one do you suggest to use?
what shall do?
|
|
|
|
|
Hi,
Try this:
if (!IsPostBack)
{
using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["PersonTest"].ConnectionString))
{
conn.Open();
using (SqlCommand cmd = new SqlCommand("SELECT CityName , id FROM City", conn))
{
DataTable dt = new DataTable();
SqlDataAdapter adpt = new SqlDataAdapter(cmd);
adpt.Fill(dt);
DropCity.DataTextField = "CityName";
DropCity.DataValueField = "CityId";
DropCity.DataBind();
}
}
}
All the best..
|
|
|
|
|
Hello,
I want to detect when user click back button in android webkit.
I can detect back button event by below code.
But it does not work in android webkit.
Response.Cache.SetNoStore();
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Is there any way to catch back button button?
hi
My english is a little.
anyway, nice to meet you~~
and give me your advice anytime~
|
|
|
|
|
i want to build my own project please help me .......by giving guide...send the guidelines to my account......
|
|
|
|