|
hi,
im new at asp.net programming. In my menu there are 2 department, dept1 & dept2.Recently i have designed a website. Website's menu is designed by html and css.
Now i registered 2 user using asp.net web administration tool. User1 for dept1 and user2 for dept2. User1 can not access the page under dep2. Now the problem is when I click dept2 as user1, it shows me http404 error that the contents can not be found. Now what I want is if I click dept2 as user1 it will take me to the login page again. Again I made up that menu using css and html.
Any suggestion?
Thank You
|
|
|
|
|
I would suggest either setting the menu items visibility in the code behind depending on the roles (if the user does not have access why even display the menu item to them) or to load the menu items dynamically from the database by associating menu items to roles, and using the current users role to load the menu items and build your menu like that.
No matter how long he who laughs last laughs, he who laughs first has a head start!
|
|
|
|
|
I have a web page in which there is GridView binded with some records.
There are two buttons i.e. delete button and update button in the grid. Now When i click delete button, then the RowCommand event fires and it works perfectly. But when I click on update button to update the current row and then clicks on delete button to delete any row, then the following error occurs :
Invalid postback or callback argument. Event validation is enabled using <pages enableeventvalidation="true"> in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation
I have also used "EnableEventValidation='False'" in the page.aspx
but still getting same error ..
Kindly help ASAP
|
|
|
|
|
Since the sever generated the object, it expects to have full control over it. So the delete has to delete in the server side post back, and then rendered again on page load. It's a security issue in asp.net. You can wrap the object in an update panel, and so a small ajax trip to the server and back, while maintaining server side control.
|
|
|
|
|
I am adding a checkboxlist control to a C# asp.net 2010 since I am new to working with web pages. The following code works if I hardcode the value in the where clause. However, I want to pass the value in the where clause as a paramter. Thus can you tell me what I could change in the code below to pass the value to the where statement not as a hardcoded value?
[^]DBConnection.FillAttChkListBox(ChkBoxLstPlan, "Hnumber", "Hnumber",
DBConnection.ExecuteQuery("select p.Hnumber from dbo.Org o inner join Pl p on o.OrganizationID =p.OrganizationID where OrganizationName='orgname1'"), false);
public static DataTable ExecuteQuery(string SQLstring)
{
string constr = ConfigurationManager.ConnectionStrings["DBConnectionString"].ConnectionString;
//string constr = ConfigurationManager.ConnectionStrings["Client_ServiceConnectionString"].ConnectionString;
SqlConnection conn = new SqlConnection(constr);
DataTable dt = new DataTable("tbl");
using (conn)
{
conn.Open();
SqlCommand comm = new SqlCommand(SQLstring, conn);
comm.CommandTimeout = 0;
SqlDataAdapter da = new SqlDataAdapter(comm);
da.Fill(dt);
}
return dt;
}
public static void FillAttChkListBox(CheckBoxList chklistBox, String dataValueField, string dataTextField, DataTable dataTbl, bool bHasBlank)
{
chklistBox.DataTextField = dataTextField;
chklistBox.DataValueField = dataValueField;
chklistBox.DataSource = dataTbl;
chklistBox.DataBind();
if (bHasBlank)
{
chklistBox.Items.Insert(0, new ListItem());
// chklistBox.Items.Insert(1, new ListItem("All"));
}
}[^]
|
|
|
|
|
You can try to make this select statement in a string variable
so you can concatinate your string variable in the where clause
Like that
string query="select p.Hnumber from dbo.Org o inner join Pl p on
o.OrganizationID =p.OrganizationID where
OrganizationName='"+AnyStringVariable+"'";
so that you can add any value in the where clause.
Try This , if it is not working , try to contact me .
Good Luck
Sincerely,
Ibrahim Hebeish | SoftwareDeveloper | Portal Services | EgyptNetwork(Com)
M: +201281744594
Email: i.hebeish@egyptnetwork.com
|
|
|
|
|
|
DBConnection.ExecuteQuery("select p.Hnumber from dbo.Org o inner join Pl p on o.OrganizationID =p.OrganizationID where OrganizationName='orgname1'")
you can make it like that :
string organizationName=_organizationNameTextBox.Text;
string query="select p.Hnumber from dbo.Org o inner join Pl p on
o.OrganizationID =p.OrganizationID where
OrganizationName='"+organizationName+"'";
DBConnection.ExecuteQuery(query)
so you can pass any value to the "Where" Clause (it is simple way).
or
you can make a Stored-Procedure that makes the same Query &
takes a parameter for the Where clause and this is the (recommended solution).
Sincerely,
Ibrahim Hebeish | SoftwareDeveloper | Portal Services | EgyptNetwork(Com)
M: +201281744594
Email: i.hebeish@egyptnetwork.com
|
|
|
|
|
Hi all,
I have this piece of code which sends the pdf to printer, using AcroRd32.exe to achieve this.
for (int i = 2; i <= 3; i++)
string filename = @"\c:\myfile" + i + ".pdf";
string parameters = String.Format(@"/t ""{0}"" ""{1}""", filename, printername);
ProcessStartInfo processStartInfo = new ProcessStartInfo(pdfpath, parameters);
Process process = Process.Start(processStartInfo);
process.WaitForInputIdle(80 * 1000);
process.Kill();
}
I want to print multipe pdfs for this. I put this logic in a for loop. For some reason it does not print the second document. Does the kill completely kill the entire process?
|
|
|
|
|
There is no open brace character "{" after your for statement.
|
|
|
|
|
Hey friends,
I am having a minor problem regarding the use of javascript function in my asp.net page.
Whts the cause of malfunctioning?
The code is as follows:
<script type="text/javascript">
function ask() {
return confirm('Do u really want to delete?');
}
</script>
<asp:Button ID="btnDeletewithoutfn" OnClientClick="javascript:return confirm('Do u really want to delete?');" Text="Delete" CommandName="Delete" runat="server" />
<asp:Button ID="btnDeletewithfn" OnClientClick="ask()" Text="Delete" CommandName="Delete" runat="server" />
The button
btnDeletewithoutfn works as intended i.e. page posts back if user clicks Ok otherwise not.
But the button
btnDeletewithfn always posts back regardless the user clicks Ok or Cancel.
Any guidance about the problem presented.
|
|
|
|
|
that's because you aren't returning the value of the response from your call to the ask() function.
try the following:
<asp:Button ID="btnDeletewithfn" OnClientClick="return ask();" Text="Delete" CommandName="Delete" runat="server" />
as if the facebook, twitter and message boards weren't enough - blogged
|
|
|
|
|
Thanks, Dennis and Alok
|
|
|
|
|
In an attempt to do human detection for a support web page, I've come up with a scheme I think might be viable, and I wanted to run it past you guys.
The idea is to present a table with a randomly selected number of columns (from three to five), with two rows. the first row contains images, and the second row contains Submit buttons.
The images that can be presented (at least 20, probably more) are contains in a folder with descriptive names, such as "green square", "dog", or "car". When a user goes to the page, the files are randomly selected, and for each file, a file name based on a quid is created, and the original file is copied to a temp folder with the guid file name. One of the selected files is randomly selected as the "correct" image, and the user is prompted to click the appropriate button (based on its original file name, like this:
"Click the submit button under the picture of XXXXX"
where "XXXXX" is the name of the original file (minus the extension, of course). So, if one of the displayed files was "dog 01.jpg", a guid file name would be generated like this - "00000000-0000-0000-00000000.jpg" - and the control's ImageUrl is set to this guid file name, and the prompt would read "Click the Submit button under the picture of the dog."
This mechanism is intended to prevent bots from learning the system by looking at the image name, or expecting a fixed number of choices, and still allows a number of "dog" images to be used so that the image isn't the same every time the page is presented. Post-backs would delete the temporary images.
What do you guys think? Will it be effective?
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
|
|
|
|
|
The biggest problem is the small number of choices. The bot could choose choice #1 a thousand times and be right often enough to keep spamming.
Captchas make it so that the bot can try a thousand times and still be wrong a thousand times. Captchas aren't perfect, but I don't know anything better.
|
|
|
|
|
But the choices (and number of choices) changes every time the page is refreshed.
That means every attempt could still be wrong.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
|
|
|
|
|
If the page has 3, 4, or 5 submit buttons per page, and a completely random submit button is the correct one each time, then choosing the first submit button you see will be correct about 25% of the time.
Assume your website creates user accounts and a spam bot wants to create spam user accounts. The spam bot could be programmed to choose the first submit button every time and to simply ignore all text and pictures. In the end, 75% of the time, the web page will reject the user account, and 25% of the time, the spam bot will successfully create a spam user account. If the spam bot tries 1000 times, it will create about 250 spam user accounts.
I assume the final result of 250 successfully-created spam accounts per 1000 spam attempts is not desirable.
|
|
|
|
|
This is just for send an email, not creating accounts.
BTW, it's widely known that most/all captcha systems have been broken - that's why I'm not considering their use.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
|
|
|
|
|
Captcha systems aren't perfect, but it takes really advanced algorithms to break them. The system you proposed could be broken with simple algorithms that don't require image analysis.
I think your best defense is a good spam filter for your email address; if it's posted on a public website, it will get picked up by spammers, and most IT departments already have high quality spam filters, as the vast majority of email they get is spam.
If you're adding the additional protection of making it hard for spammers to automatically scrape the email address from the website, any simple submit before displaying the email address should do, as the spammers won't be targeting your website specifically.
|
|
|
|
|
The email address itself isn't presented anywhere. The user has to send email through the web site.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
|
|
|
|
|
I know that Membership uses it's own database. But can we use direct Membership to use our own tables and perform the same functions.
|
|
|
|
|
Yes Membership provider uses it's own predefined tables. But if you wnt to use your own custom tables then you need to write your custom membership provider. Lots of tutorials available for this. You can find it easily.
|
|
|
|
|
yes ,u can do this by providing your set of logic to validate the user.
|
|
|
|
|
I have a C# asp.net 2010 web page where would like to see how to setup code for the following:
I would like users to enter an organiztion name in a textbox. I would then like to take the organization name that is in the textbox and tie it to a checkboxlist control. The checkbox list control will contain all the suborganizations associated with the main organization. (For your information the cehckbox list control will be used by the users for other selections.)
I am asking for this code since the smart code that I use in the designer is not giving me a selection the textbox control as an option for me to tie the code together.
|
|
|
|
|
Why don't you write custom code for this.
|
|
|
|