|
In order to understand them, you need to understand what an accessor means. The accessor of a property contains the executable statements associated with getting (reading or computing) or setting (writing) the property. The get and set keywords are accessors to a property. The code block for the get accessor is executed when the property is read; the code block for the set accessor is executed when the property is assigned a new value. A property without a set accessor is considered read-only. A property without a get accessor is considered write-only. A property that has both accessors is read-write. Here is a simple example(not the perfect example though ) of a class that uses get and set.
class KgToLbsConverter
{
public double _qty;
public bool _isKgs;
public KgToLbsConverter(double qty)
{
_qty = qty;
}
public bool QuantityIsInKilograms
{
get { return _isKgs; }
set { _isKgs = value; }
}
public double Kilograms
{
get
{
if (_isKgs) { return _qty; }
else { return _qty * 2.20462262; };
}
}
public double Pounds
{
get
{
if (!_isKgs) { return _qty; }
else { return _qty / 2.20462262; };
}
}
}
and then in your main program, you can test the class with a code snippet something like this
KgToLbsConverter convert = new KgToLbsConverter(1);
convert.QuantityIsInKilograms = true;
You can refer to the following links for more information.
Accessors - http://msdn.microsoft.com/en-us/library/aa287786%28VS.71%29.aspx
Properties - http://msdn.microsoft.com/en-us/library/w86s7x04.aspx
Get Keyword - http://msdn.microsoft.com/en-us/library/ms228503.aspx
Set Keyword - http://msdn.microsoft.com/en-us/library/ms228368.aspx
Walter
|
|
|
|
|
Hi,
I have created login for site. I am using "UserLogin.ascx" which is placed in masterpage. Now I have to create the Login system so that the users from other sites login to my site through Http post or Get. I have created the page for sending "HTTP Post" to my site and it also login to my site, but when I click on any link it logs out also in the browser's address bar the URL of the previous site is shown.
Thanks
|
|
|
|
|
Hello,
I am a developer in ASP.NET (C#). Recently I am studying on SEO in order to upgrade my Web Application, and I learned that, Google bot reduce the rank if it finds duplicate content. thats fine, but what is bothering me, is, if I have urls as
http://myWebsite.com
http://www.myWebsite.com
http://myWebsite.com/Default.aspx
http://www.myWebsite.com/Default.aspx
Then, my site rank will be down, as Google will think that, I have same content in 4 urls. BUT, my Question is WHY!!!!, Google, the world's best search engine, does not have such intelligence to evaluate these 4 urls as single url !! ? Cant they simply add some additional if-else logic to determine these urls ? Also I learned that, the urls must be case sensitive. That means, in Windows Hosting, myWebsite.com and MyWEBSITE.COM points to the same file, but Google search engine will reduce rank for this. Again !! I dont know, cant Google bot do some case insensitive string comparison ? What a HELL !!
Also, found many upsetting topics to discuss about SEO, but for now, my question about these 2 scenarios. Would you please share your opinions ?
|
|
|
|
|
I don't think you understand what you are reading very well.
The more distinct sites that link to your site the higher the rank. If you use several different URLs then it seems like you are trying to artificially increase the number of sites that link to your content. Just because your site can be referred to that way doesn't mean you have to. If you are consistant in the way you link internally and the way you advertise your site you won't have a problem.
URLs are case sensitive. That is the way the web was built. Not everyone uses windows hosting. mywebsite.com/Thing and mywebsite.com/thinG are two completely different URLs on a Unix system.
All of these things are easily avoidable if you are consistant in how you develop and market your site. So unless you have some medical condition that causes random spasms over your caps lock key, you are doing a lot of whining over nothing.
|
|
|
|
|
Hi Gray,
Thanks for your answer. I searched in google with the key word 'search engine optimization duplicate content' and found the first link at http://www.seobythesea.com/?p=212[^]
In this article, at #4, I found the following paragraph:
4. Canonicalization issues, where a search engine may see the same page as different pages with different URLs
Because search engines index URLs rather than pages, it’s possible for them to index the same pages that is presented different ways. A “canonical URL” is one that is determined to be the “best” URL for a page, but search engines don’t always recognize that the same page is being presented multiple ways. For example, the following URLs may all point to the same page:
http://www.example.com
https://www.example.com
http://www.example.com/index.htm
https://www.example.com/index.htm
http://example.com
https://example.com
http://example.com/index.htm
https://example.com/index.htm
=======================
Also, I read many articles on SEO where they talked the same thing about urls as mentioned in the above paragraph. Thats why I was wondering!!
|
|
|
|
|
Hi,
I have listview with itemtemplates. so listview's each row is in the format as
<checkbox><Label><checkbox><HiddenField>
In design it looks similar to as
asp:ListView ID="ListviewSelectedBaseLayers" runat="server" DataKeyNames="Layer_ID">
..
..
<ItemTemplate>
<tr id="check_1">
<td style="text-align: center">
<asp:CheckBox ID="chkSelect" runat="server" AutoPostBack="true" />
</td>
<td>
<asp:Label ID="lblLyrName" runat="server" Text='<%#Eval("LayerName")%>' ></asp:Label>
</td>
<td style="text-align: center">
<asp:CheckBox ID="chkDefaultlayer" runat="server" AutoPostBack="true" Checked='<%#Eval("DefaultLayer")%>' />
</td>
<td style="display:none">
<asp:HiddenField ID="hdRank" runat="server" Value='<%# Eval("Rank") %>' />
</td>
</tr>
</ItemTemplate>
Now when I click on checkbox or the label, listview's selected row does not hilight.
How to achieve this? I tried by toggling the colour of the table covering table row by putting onclick javascript for the label.
Did not find enough information on this ? So if anybody give some tips will really help.
thanks
vijay
|
|
|
|
|
You can do it through the onclick event of the tr element. Here's a simple snippet of what you might want to do.
<tr style="border:solid 1px Black;" onclick="ToggleColor(event);">
And on the function
function ToggleColor(ev) {
var tar;
if (ev.srcElement != null) {
tar = ev.srcElement.parentElement;
}
else {
tar = ev.currentTarget;
}
if (tar.bgColor == "#eeeeee") {
tar.bgColor = "#ffffff";
}
else {
tar.bgColor = "#eeeeee";
};
}
Hope this helps.
Walter
|
|
|
|
|
if you can make the list view render as divs I think you can use jQuery Highlight[^] Effect. good luck
|
|
|
|
|
Hi,
I've got a MasterPage and another page Default.aspx
In the MasterPage there's a form to make the server side controls run.
In Default.aspx there are a lot of Inputs and I need to send that data to another page (Exec.aspx)
I tryed adding another form in Default.aspx, but it doesn't appear in the HTML, so I decided to change the action of the form in the MasterPage.
I Used this code:
Protected Sub Page_PreInit(ByVal sender As Object, ByVal e As System.EventArgs)
CType(Me.Master.FindControl("Form1"), HtmlForm).Action = "Exec.aspx"
End Sub
But it raises an error:
"Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that <machineKey> configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster."
What can I do???? Please help me!
PS: I can't send the data by GET method
|
|
|
|
|
|
You are right, but I would like to send the data to another page that handles tha data and does other things.
However, thanks for your advice, but I solved the problem creating a third page and requesting it via AJAX.
|
|
|
|
|
95ulisse wrote: I solved the problem creating a third page and requesting it via AJAX
Of course, every problem can be solved by another level of indirection
Just because you can doesn't mean you should. Design the solution correctly and it will limit your problems in the future.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
You are right, but in this way my page doesn't need to refresh
and I think it's better for the user!
|
|
|
|
|
You don't need a third page to make use of AJAX. You are adding complexity where it is not necessary which will make your application more difficult to maintain and enhance.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Hi,
I have a checkboxlist which is databound in code behind.
chkListBaseMaps.DataSource = oDataSet
chkListBaseMaps.DataTextField = "LayerName"
chkListBaseMaps.DataValueField = "Layer_ID"
chkListBaseMaps.DataBind()
I get the checkboxlist ordered on Layer_ID.
I delete/insert items in checkboxlist and do the same with associated dataset and bind the chklistbox again.
What I need is everytime I bind the checkboxlist, i need the checkboxlist to be ordered (sorted as ASC) on LayerName field which is datatextfield. How to do that?
thanks
vijay
|
|
|
|
|
Why not use DataView to associate with checkboxlist and bind it?
Do all you need with dataview... sorting... filtering!
Thus, this line would change: chkListBaseMaps.DataSource = oDataSet oDataView
|
|
|
|
|
Yep helped it
Thanks a lot
vijay
|
|
|
|
|
So i worked about a year with asp.net with vs 2003 and .net2.
Looking to restart where i left with the brand new vs 2010 with asp.net webforms (mvc looks too different and i am a bit tight on time to relearn the whole thing).
However my deployment server is a Windows Server 2003, can i work with VS 2010 asp.net webform project or would it be better for me to downgrade to a previous version of Visual Studio?
Thanks in advance
|
|
|
|
|
Or maybe this is a better way of phrasing this,
Is there a way to target IIS 6 with Visual Studio 2010?
|
|
|
|
|
Hi,This is first time that i am trying to connect to an OPC server(KEP and MATRICON). I dont have any idea about it, so please can anybody guide me through how to connect to an OPC server(KEP and MATRICON) & fetch values from it. I am using ASP.net with C#.
Thanks in advance.
modified on Tuesday, June 1, 2010 8:03 AM
|
|
|
|
|
Dear friends,
I want to fetch data from Excel sheet sheet1 using ASP.NET with C# and store the data in SqlServer database table using BulkCopy method. I am able to fetch complete excelsheet data, but I want only some rows. I want sql statement to fetch the data. Excel sheet contains one Date column. I want to fetch data from only particular dated rows. I am writing the following query
select * from [Sheet1$] where Date=21/04/10 It is giving me error datatype mismatch. Please, can anyone help me. It's very urgent. Pls....
Thanks,
Dileep.
|
|
|
|
|
Try the following query:
select * from [Sheet1$] where Date='04/21/2010'
Note that the date should be in mm/dd/yyyy format and within single quote(').
|
|
|
|
|
Dear Anurag,
I am still getting this following error.
[System.Data.OleDb.OleDbException] = {"Data type mismatch in criteria expression."}
I have written the following code.
filename = path + "SS_EmpLoginTimings.xls";
string s = "provider=Microsoft.Jet.OLEDB.4.0;" + @"data source=" + filename + ";Extended Properties=Excel 8.0;";
OleDbConnection con = new OleDbConnection(s);
con.Open();
OleDbDataAdapter da = new OleDbDataAdapter("select * from [Sheet1$] where Date='04/21/2010'", con);
DataSet ds = new DataSet();
da.Fill(ds);
DataTable dt = ds.Tables[0];
BulkCopyData(dt, "SS_EmpLoginTimings");
public bool BulkCopyData(DataTable dt, string tblName)
{
SqlBulkCopy bulk = new SqlBulkCopy(conn);
bulk.DestinationTableName = tblName;
conn.Open();
bulk.WriteToServer(dt);
conn.Close();
return true;
}
Please help me. It's very urgent. I need to finish this work by today evening. Pls pls pls...
Regards,
Dileep.
|
|
|
|
|
Have you got da and ds the wrong way round in the da.fill(ds)?
It's while since I coded anything like this so I could be totally wrong.
Maybe try putting the criteria as Date = '21-Apr-2010'.
|
|
|
|
|