|
I need to open access file (accde) inside web browser in asp.net,what do I do?
|
|
|
|
|
Is it a bad pratice to add a value to ViewBag and hide and show controls based on it's value? Example:
@if (ViewBag.Role == "Admin")
{
@Html.TextBoxFor(m => m.UserName)
@Html.ValidationMessageFor(m => m.UserName)
}
Also, if it is a good way to do things how would you use it to hide and show the parent View's partial views helper controls?
|
|
|
|
|
As ViewBag is valid only for the current request, that means you have to reinitialize Role on every request. You better using session-wide storage (like TempData) for such info...
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
Thank you for your post. Would it not be better to have a USER Entity Framework table, which contains the the roles ID, and in the controller assign it to the modle value returned to the View like this:
@if(role.ID)
{
...
Now, this is how my boss wants to do it. Have the database that contain a USER table which has a role permissions enum value, then when the Controller looks up the user by AD value the role is checked and used to hide and show UI elements.The only questions I have are these: Along with the USER Entity model object for the Role we are passing back the RECORD Entity which contains data to fill Grids and text boxes to be bound to the View and all of it's partial Views. First, how do we pass back to the View both the ROLE the the RECORD entity data? Second if we use some kind of helper that contains the role can both the main View and it's Partial Views use the helper to hide and show the View controls?
|
|
|
|
|
It sound me a bit over-made...
Search for 'role based authorization in mvc' in Google and you will learn that most of the things you try to develop here already exist...
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
Now, Im confused. Could you point me to an article explainning this?
|
|
|
|
|
|
I am using the demo provided with the An Expandable .NET Gridview article. When I expand and contract the same row twice, the first time it works OK, but the second time all the content on the detail row is condensed on the first cell of the table. I'm looking at the source code and I have no idea where to look to find the source of this problem. Please help.
|
|
|
|
|
Why not post the question to the author? Use comments section at the bottom of the article...
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
You are using a ASP.NET and ADO.NET to create an accounting application for your company.
You are writing code to run a set of stored procedures that perform posting operations in a
database at the end of each month. You use an OleDbConnection object to connect to the
database. You use an OleDbConnection object to connect to the database. You use an
OleDbCommand object to run the stored procedures. If an error occurs during execution of any
of the stored procedures, you want to roll back any data changes that were posted. You want the
changes to be committed only if all of the posting operations succeed. You write code to catch an
OleDbException object if an error occurs during the execution of a stored procedure. What else
should you do?
1. Call the Begin Trasaction method of the OleDbConnection object before running the stored
procedure. If an error occurs, use the OleDbConnection object to roll back the changes.
2. Call the BeginTransaction method of the OleDbConnection object before running the stored
procedures. If an error occurs, use the OleDbException object to roll back the changes.
3. Use the BeginTransaction method of the OleDbConnection object to create an
OleDbTransaction object. Assign the OleDbTransaction object to the Transaction property of
your OleDbCommand object. If an error occurs, use the OleDbTransaction object to roll back
the changes.
4. Use the BeginTransaction method of the OleDbConnection object to create an OleDbTransaction object. Pass a reference to the OleDbTransaction object to each stored procedure. Use error handling inside the stored procedures to roll back the changes
priya
|
|
|
|
|
Problems with homework? Let do yourself a favor - at least try to do it alone!!!
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
I m sorry.. But i couldn find out the correct answer......
|
|
|
|
|
And you will not. Except your teacher posted it somewhere on the web...
The only way is to get together all you learned and try to create a solution. If you have a solution that doesn't work correctly (some error) you always can come back here an ask about that specific error, however you will not get an out-of-box solution here specially for home-work assignments...
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
Thank You...
I'll try to get it done and find solution for this...
|
|
|
|
|
I want to know how to validate a textbox does not begin with the number 2
|
|
|
|
|
Use a RegularExpressionValidator[^]:
<asp:RegularExpressionValidator runat="server"
ControlToValidate="TheTextBox"
ValidationExpression="[^2].*"
ErrorMessage="The text must not start with '2'."
/>
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
thank you, It worked, please I'm looking for documentation on the regular Expression.
|
|
|
|
|
Regular expressions are a very complex topic, but there are lots of resources to help:
This specific expression - [^2].* - means:
- any character other than '2' (
[^2] ), - followed by zero or more repetitions (
* ) - of any character (
. ) at all.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Use regex.
Please try doing the regex examples http://regexone.com/[^]
Please up vote if it helped you
Thanks And Regards
Sibeesh
|
|
|
|
|
Hi,
I have Create Dynamic Controls on dropdown SelectedIndexChanged event
protected void ddlcount_SelectedIndexChanged(object sender, EventArgs e)
{
Table tbldynamic = new Table();
for (int i = 1; i <= count; i++)
{
tr = new TableRow();
tc1 = new TableCell();
tc2 = new TableCell();
tc3 = new TableCell();
tc4 = new TableCell();
TextBox _txtQty = new TextBox();
_txtQty.ID = "txtQtyRow" + i;
_txtQty.Width = 50;
TextBox _txtRate = new TextBox();
_txtRate.ID = "txtRateRow" + i;
_txtRate.Width = 50;
TextBox _txtAmount = new TextBox();
_txtAmount.ID = "txtAmountRow" + i;
_txtAmount.Width = 50;
CheckBox _chkRowNo = new CheckBox();
_chkRowNo.ID = "chkRowNo" + i;
_chkRowNo.Text = i.ToString();
tc1.Controls.Add(_txtQty);
tc2.Controls.Add(_txtRate);
tc3.Controls.Add(_txtAmount);
tc4.Controls.Add(_chkRowNo);
tr.Cells.Add(tc4);
tr.Cells.Add(tc1);
tr.Cells.Add(tc2);
tr.Cells.Add(tc3);
tbldynamic.Rows.Add(tr);
}
}
I need to get values from dynamically generated Textbox on Button Click Event.
I am trying below,
protected void btnSave_Click(object sender, EventArgs e)
{
CheckBox chk = (CheckBox)Page.FindControl("MainContent").FindControl("MultiviewId").FindControl("view1").FindControl("Panel1").FindControl("chkRowNo1");
}
Here
MainContent = ContentPlaceHolderID,
MultiViewId = MultiView,
ViewId = view1,
PanelId = Panel1,
chkRowNo1 = Dynamically generated checkbox
I have also tried
CheckBox chk = (CheckBox)Page.FindControl("chkRowNo1");
CheckBox chk = (CheckBox)Panel1.FindControl("chkRowNo1");
But no use. It shows an object reference error. While debugging it shows null.
Some one could you help me...
|
|
|
|
|
Hi
I want check box list combobox control in asp.net can any one help me?
Thanks
|
|
|
|
|
|
Thanks
|
|
|
|
|
Hello
I have three files in my simple 'Registration form' project - it inserts new user details into a MS Access database - comprising
an aspx, aspx.vb, and a Web.config file.
If I may post some of the code here, I was wondering if I can delete the following Sub Page_Load() from my aspx.vb file since I
can't see the purpose of it. In that aspx.vb file, I have:
Sub Page_Load()
Dim myMDBConnection As OleDbConnection = New OleDbConnection(ConfigurationManager.ConnectionStrings("Register").ToString().Trim())
myMDBConnection.Open()
'do stuff here
myMDBConnection.Close()
End Sub
Protected Sub CreateUser_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim conn As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data source=C:\myDatabase.mdb;")
Using conn
Dim Sql As String = "INSERT INTO userlist (username,password, strEmail) VALUES (@username,@password, @strEmail)"
Dim cmd As New OleDbCommand(Sql, conn)
conn.Open()
cmd.Parameters.AddWithValue("@username", username.Text)
cmd.Parameters.AddWithValue("@password", password.Text)
cmd.Parameters.AddWithValue("@strEmail", strEmail.Text)
cmd.ExecuteNonQuery()
conn.Close()
End Using
End Sub
End Class
And in my Web.config file I have:
<?xml version="1.0"?>
<configuration>
<connectionStrings>
<add name="Register" providerName="Microsoft.Jet.OLEDB.4.0;"
connectionString="C:\myDatabase.mdb;" />
</connectionStrings>
</configuration>
Would it be 'safe' to remove that Sub Page_Load()?
Thank you for any advice.
|
|
|
|
|
Look safe to me to delete, I don't see it really doing anything
|
|
|
|