|
|
|
I have a listview control in that i put radiobutton but i can't find when the radio button is clicked..
my code is here
<asp:ListView ID="ListView2" runat="server" ItemPlaceholderID ="BrandName" OnSelectedIndexChanged="ListView2_SelectedIndexChanged" OnSelectedIndexChanging="ListView2_SelectedIndexChanging" OnItemCommand="ListView2_ItemCommand">
<LayoutTemplate >
<ul>
<asp:PlaceHolder runat ="server" id="BrandName"></asp:PlaceHolder>
</ul>
</LayoutTemplate>
<ItemTemplate>
<li><asp:RadioButton ID="rodB1" runat="server" GroupName="G3" OnCheckedChanged="rodB1_CheckedChanged" AutoPostBack="True" /><%#Eval("Brand")%></li>
</ItemTemplate>
</asp:ListView>
|
|
|
|
|
Hi,
I think to view the controls in the list box or gridview, we need to provide some data source.
Here i have tried some code to view the radio button control in the list view.
<asp:ListView ID="lv1" GroupItemCount="3" runat="server" DataKeyNames="1" >
<LayoutTemplate>
<fieldset>
<legend>MyGroups</legend>
<asp:PlaceHolder runat="server" ID="groupPlaceholder"></asp:PlaceHolder>
</fieldset>
</LayoutTemplate>
<GroupTemplate>
<fieldset>
<legend>Individual Group</legend>
<asp:PlaceHolder runat="server" ID="itemPlaceholder"></asp:PlaceHolder>
</fieldset>
</GroupTemplate>
<GroupSeparatorTemplate>
</GroupSeparatorTemplate>
<EmptyDataTemplate>No records present.</EmptyDataTemplate>
<ItemTemplate>
<asp:RadioButton ID="RadioButton1" runat="server" AutoPostBack ="true" value='<%# Eval(1)%>' /><%# Eval("Text1")%>
</ItemTemplate>
</asp:ListView>
**********************************************
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
BindListView()
End If
End Sub
Private Sub BindListView()
lv1.DataSource = GetData()
lv1.DataBind()
End Sub
Private Function GetData() As DataTable
Dim dt As New DataTable()
dt.Columns.Add("1", System.Type.[GetType]("System.Int32"))
dt.Columns.Add("Text1", System.Type.[GetType]("System.Int32"))
Dim k As Integer = 0
Dim strTemp As String = 10
For i As Integer = 0 To 11
Dim dr As DataRow = dt.NewRow()
dr("1") = i + 13
dr("Text1") = 10
k += 1
If k = 3 Then
strTemp = 12
k = 0
End If
dt.Rows.Add(dr)
Next
Return dt
End Function
once try this code
I can't provide the answer, but have provide some suggestions.
Prasad Vj
|
|
|
|
|
Soliciting opinions. I'm an ASP.NET dev, and I've got the opportunity to work on a project that will be in ASP.NET MVC, which I know little about. Am I right in thinking that it's a pared-down version of ASP.NET that enforces a design template and offers lots of other syntactic sugar to cover up the inner workings of standard ASP.NET, or is there more to it? I've previously done some Silverlight, but wouldn't choose to do another due to its likely demise. There's no connection between ASP.NET MVC and WPF, right? Thoughts on the future of ASP.NET MVC?
|
|
|
|
|
First take a look at comparisons
WebForms vs. MVC[^]
Difference betweeen ASP.NET WebForms and ASP.NET MVC[^]
woopsydoozy wrote: There's no connection between ASP.NET MVC and WPF, right? You mean Silverlight? Even it's WPF, AFAIK No. Silverlight/WPF's way is XAML. You could use things like WCF, LINQ on both MVC & WPF/SL.
woopsydoozy wrote: Thoughts on the future of ASP.NET MVC? Nowadays people prefer MVC over ASP.NET webforms. And people use MVC with javascript libraries, here couple of articles from CP.
MVC Techniques with jQuery, JSON, Knockout, and C#[^]
ASP.NET MVC 4 with Knockout Js[^]
Simple CRUD Using Backbone.js in ASP.NET MVC Razor[^]
AngularJS Single Page Application with WebAPI and Upida backend[^]
Design and Develop a website using ASP.NET MVC 4, EF, Knockoutjs and Bootstrap : Part - 1[^]
ASP.NET MVC 4 SPA Navigation with Sammy.js[^]
thatrajaCode converters | Education Needed
No thanks, I am all stocked up. - Luc Pattyn
When you're wrestling a gorilla, you don't stop when you're tired, you stop when the gorilla is - Henry Minute
|
|
|
|
|
I'm still trying to wrap my head around this, so I'm not even sure I will be asking the right question...
I have a method that makes a call to a web service to get a result set. That result set is returned to the caller in Json format.
When the method makes the request to the service, is that an HTTPGET or an HTTPPOST request?
If the answer is it depends, is there a way to distinguish between the 2?
How do I know when I need to include the JsonRequestBehavior.AllowGet argument on my Json call?
public virtual ActionResult ListAjax([DataSourceRequest] DataSourceRequest request)
{
var d = myWebService.GetD(s, c, f);
var dList = d.Select(x => x.DId).ToList();
DataSourceResult result = d.ToDataSourceResult(request);
return Json(result);
}
modified 31-Jan-14 7:15am.
|
|
|
|
|
Hi
When you are calling a method you will mention whether you are doing get or post.
You can make use of Fiddler tool when making webservice call. You will come to know whether you are doing get or post request.
Can you paste the code snippet that is making web service call.
|
|
|
|
|
Thank you for the tip. Using fiddler, I was able to tell that the request was a POST. I just thought there should be some way I should be able to tell by looking at the WSDL.
|
|
|
|
|
By looking at wsdl you will not be able to tell. Wsdl is web service link
|
|
|
|
|
im having some troubles in firing imagebutton click event in a user control which is loaded when the combo selectedIndexChanged event fires...
the user control is this
<div id="rowsBg" class="rowsBgSearchStaff" runat="server">
<div id="trashHolder" class="buttonHolder">
<asp:ImageButton ID="btnTrash" CssClass="btnTrashSearch" ToolTip="حذف"
ImageUrl="~/img/btnsearchtrash.png" runat="server" onclick="btnTrash_Click" />
</div>
<div id="separator1" class="separatorSearchStaff">
</div>
<div id="editHolder" class="buttonHolder">
<asp:ImageButton ID="btnEdit" CssClass="btnEditSearch" ToolTip="ویرایش"
ImageUrl="~/img/btnsearchedit.png" runat="server"
onclick="btnEdit_Click" />
</div>
<div id="separator2" class="separatorSearchStaff">
</div>
<div id="infoStaffHolder" class="staffinfoHolder">
<asp:Label ID="lblStaffInfo" runat="server">Name, Family, Code</asp:Label>
</div>
</div>
and these are events:
protected void btnTrash_Click(object sender, ImageClickEventArgs e)
{
dbm.Execute(String.Format("delete from Staff where Code='{0}'", StaffCode));
dbm.Execute(String.Format("delete from Contract where StaffCode='{0}'", StaffCode));
dbm.Execute(String.Format("delete from WardStaffs where StaffCode ='{0}'", StaffCode));
rowsBg.Visible = false;
}
protected void btnEdit_Click(object sender, ImageClickEventArgs e)
{
Response.Redirect(String.Format("EditStaff.aspx?sid={0}", StaffCode));
}
TIP: dbm is an instance of my databasemanager class
in my aspx page I use below codes to add control manually
protected void cmbBxWard_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
{
if (dbm.Read(String.Format("select * From Staff where Staff.Code in (select StaffCode from WardStaffs where WardCode={0})", cmbBxWard.Items[cmbBxWard.SelectedIndex].Value)))
{
foreach (DataRow dr in dbm.DT.Rows)
{
Control cnt = Page.LoadControl("StaffItem.ascx");
StaffItem staff = (StaffItem)cnt;
staff.StaffCode = dr["Code"].ToString();
itemHolder.Controls.Add(staff);
}
}
}
itemHolder is my div tag which hast runat="server" attribute
StaffItem is my control
after I change the selected item in my combobox I will click the btnEdit of my control
but it does not fire
why?
help me please
Do not Judge me...
I'm Persian!
|
|
|
|
|
i have to read the .xlsx file from SFTP server and save the con tents to the database.
i have used Renci.SshNet.dll to download the file from SFTP.
as sftpClient.DownloadFile(localfilePath, memorystream);
when i convert this memorystream into string[] as
byte[] byteArray = memorystream.ToArray();
var table = (Encoding.Default.GetString(byteArray , 0, byteArray.Length - 1)).Split(new string[] { "\r\n", "\r", "\n" }, StringSplitOptions.None);
this returns the string as encrypted text.
please help/suggest to convert this format.
|
|
|
|
|
It's not encrypted text; it's a zip file containing various parts of the Excel document.
If you're only ever dealing with .xlsx files (Excel 2007 or later), you could use the OpenXML SDK[^]. However, it will probably be easier to use a higher-level library such as EPPlus[^] or ClosedXML[^].
If you ever need to open older .xls files, then NPOI[^] is probably the simplest option.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
all is clear in the title. i have a code but i don't know why it's not working :
protected void btnUpdate_Click(object sender, EventArgs e)
{
#region @
try
{
string myid = string.Empty;
for (int i = 0; i < gv_enfant.Rows.Count; i++)
{
var chbox = gv_enfant.Rows[i].Cells[0].FindControl("CheckBoxenfant") as CheckBox;
var codeenfant = gv_enfant.Rows[i].Cells[0].FindControl("codeenfant") as HiddenField;
if (chbox != null && codeenfant != null)
{
if (chbox.Checked)
{
myid = codeenfant.Value;
}
}
}
Response.Write("myid = " + myid);
c.cmd = c.cn.CreateCommand();
c.cmd.CommandText = "update Enfants set prenom =@prenom, DateNaissance=@dateNaissance, Scolarise=@scolarise, Activite=@activite where codeEnfants=@codeEnfants";
if (c.cn.State == ConnectionState.Closed)
{
c.cn.Open();
}
c.cmd.Parameters.Add("@prenom", SqlDbType.VarChar);
c.cmd.Parameters.Add("@dateNaissance", SqlDbType.Date);
c.cmd.Parameters.Add("@scolarise", SqlDbType.VarChar);
c.cmd.Parameters.Add("@activite", SqlDbType.VarChar);
c.cmd.Parameters.Add("@codeEnfants", SqlDbType.Int);
c.cmd.Parameters["@prenom"].Value = TextBox_NPmodif.Text;
c.cmd.Parameters["@dateNaissance"].Value = TextBox_DNmodif.Text;
c.cmd.Parameters["@scolarise"].Value = TextBox_Scolarisemodif.Text;
c.cmd.Parameters["@activite"].Value = TextBox_Activitemodif.Text;
c.cmd.Parameters["@codeEnfants"].Value = myid;
c.cmd.ExecuteNonQuery();
gv_enfant.DataBind();
Response.Write("<script>alert('Opération reussie')</script>");
}
catch (SqlException sqlEx)
{
Response.Write("error" + sqlEx.Message);
Response.Write("<script>alert ('Erreur lors de la modif!')</script>");
}
finally
{
if (c.cn.State == ConnectionState.Open)
{
c.cn.Close();
}
}
#endregion
}
thank you
|
|
|
|
|
im just trying in the begenin to get the id "codeEnfants" which is hidden id the gridview in collumn 0
|
|
|
|
|
Member 10367981 wrote: i don't know why it's not working
"it's not working" is not specific enough for anyone to help you. Please describe the problem and any error messages you receive.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Hello,
You can use following code to get values.
string myid = string.Empty;
for (int i = 0; i < gv_enfant.Rows.Count; i++)
{
GridDataControlFieldCell cell = gv_enfant.RowsInViewState[i].Cells[0] as GridDataControlFieldCell;
CheckBox chbox = cell.FindControl("CheckBoxenfant") as CheckBox;
HiddenField codeenfant = cell.FindControl("codeenfant") as HiddenField;
if (chbox.Checked == true)
{
myid = codeenfant.Value;
}
}
|
|
|
|
|
How can I build a page with two listbox with sql datasource and both button in order to move items from left listbox to right listbox and double click event?
|
|
|
|
|
Have you done anything so far? Show some effort (coding) to us. As is it ain't a question...
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
Hi,
you can try this.
<div class="sellistbox">
<asp:Label ID="lblAllUsers" runat="server" Text="All ids" CssClass="sideheading"
meta:resourcekey="lblAllUsersResource1"></asp:Label>
<asp:ListBox ID="lstUserNames" SelectionMode="Multiple"
runat="server" CssClass="listbox"
meta:resourcekey="lstUserNamesResource1"></asp:ListBox>
</div>
<div class="sellistbox_btns">
<asp:Button ID="btnMoveright" runat="server" Text=">"
CssClass="cd_submitbuttons" meta:resourcekey="btnMoverightResource1" style="margin: 0 0 8px 25px"></asp:Button>
<asp:Button ID="btnMoveleft" runat="server" Text="<"
CssClass="cd_submitbuttons" meta:resourcekey="btnMoveleftResource1" style="margin: 0 0 0 25px"></asp:Button>
</div>
<div class="sellistbox">
<asp:Label ID="lblGroupUsers" runat="server" Text="Whitelisted Senderids"
CssClass="sideheading" meta:resourcekey="lblGroupUsersResource1"></asp:Label>
<asp:ListBox ID="lstUserNames2" SelectionMode="Multiple"
runat="server"
CssClass="listbox" meta:resourcekey="lstUserNames2Resource1"></asp:ListBox>
</div>
********************************************************************************
Protected Sub btnMoveright_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnMoveright.Click
Dim oCsSender_IDs As String = ""
Dim oresult As Integer
For Each lstitem1 As ListItem In lstUserNames.Items
If lstitem1.Selected = True Then
oCsSender_IDs &= lstitem1.Text & ","
End If
Next
If oCsSender_IDs = "" Then
LblResult.ForeColor = Drawing.Color.Red
LblResult.Text = " No SenderIds selected"
Exit Sub
End If
Dim omethodparams As String = ""
omethodparams = oCsSender_IDs.TrimEnd(",")
Dim ousername As String = ddlgwusers.SelectedItem.Text
oresult = objWhiteListSIDs_DAL.SaveWhiteListSIDs(ddlgwusers.SelectedItem.Value, oCsSender_IDs.TrimEnd(","), DateTime.Now.ToString())
If oresult < 0 Then
LblResult.Text = HidLblResultFail.Value
Else
LblResult.Text = HidLblResultSuc.Value
End If
LoadSenders(ddlgwusers.SelectedItem.Value, 2)
BindWhiteListSids(ddlgwusers.SelectedItem.Value)
End Sub
Protected Sub btnMoveleft_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnMoveleft.Click
Dim oCsSender_IDs As String = ""
Dim oresult As Integer
For Each lstitem1 As ListItem In lstUserNames2.Items
If lstitem1.Selected = True Then
oCsSender_IDs &= lstitem1.Text & ","
End If
Next
If oCsSender_IDs = "" Then
LblResult.ForeColor = Drawing.Color.Red
LblResult.Text = " No SenderIds selected"
Exit Sub
End If
Dim omethodparams As String = ""
omethodparams = oCsSender_IDs.TrimEnd(",")
Dim ousername As String = ddlgwusers.SelectedItem.Text
oresult = objWhiteListSIDs_DAL.DeleteWhiteListSIDs(ddlgwusers.SelectedItem.Value, oCsSender_IDs.TrimEnd(","))
If oresult < 0 Then
LblResult.ForeColor = Drawing.Color.Red
LblResult.Text = HidDelFail.Value
Else
LblResult.ForeColor = Drawing.Color.Red
LblResult.Text = HidDelsuc.Value
End If
End Sub
|
|
|
|
|
Dear all,
I am trying to construct a method, which can allow specific users to be redirected to their specific api controllers. I have come up with a psuedo-code however, I am little stuck implementing this method as i keep getting errors. Any help/advice would be very helpful.
public class MultiController : ApiController
{
if (User.IsInRole("admin"))
{
[ActionName(BwicController)]
}
else (User.IsInRole("user"))
{
[ActionName(IntexController)]
}
}
This is the class where the user credentials are stored:
public class PrincipalPro : IProvidePrincipal
{
private const string Username = "###";
private const string Password = "###";
public IPrincipal CreatePrincipal(string username, string password)
{
if (username != Username || password != Password)
{
return null;
}
var identity = new GenericIdentity(Username);
IPrincipal principal = new GenericPrincipal(identity, new[] { "admin" });
return principal;
}
}
|
|
|
|
|
I'm not sure if I understood your question correctly. If you just want single action method that behaves differently depending on user's group then just implement the logic there.
If the redirect part is important then in default action method redirect the response to correct action. However that won't stop users from typing "wrong" URL (i.e. user typing admin's url), so you would have to check access anyway.
--
"My software never has bugs. It just develops random features."
|
|
|
|
|
Thank you very much for your response.
deflinek wrote: If you just want single action method that behaves differently depending on user's group then just implement the logic there.
I would like to clarify your above statement, if you are suggesting I implement the logic in the "MultiController" class or "PrincipalPro" class.
Currently I have two users group full and limited. I have to provide data api controller (localhost/api/data) to user group 'full' and data2 api controller to user group 'limited'. I would like to be able provide one link to the users, where they login and the system automatically redirects them correct data controllers.
So my question is, that is their specific filter/method function i could use or some kind of example/framework i can use a guide for this logic, as I am currently struggling to out this together.
I hope this clarifies my issue a little clearer.
Thank you for your help.
|
|
|
|
|
I suggest to implement the logic in MultiController class. I assume you need to return different set of data depending on their role. In that case you can attribute the MultiController class with [Authorize] so you force user to login before accessing it's methods, then return different data depending on user's role.
i.e.
public SomeResult Get()
{
if(User.IsInRole("Admin"))
{
return FullData();
}
else
{
return RestrictedData();
}
}
Does it make sense?
--
"My software never has bugs. It just develops random features."
|
|
|
|
|
I am writing to seek help, as I am experiencing - No overload for method 'Get' takes 0 arguments error, on the "return result.Get();" line of user controller class.
public class UserController : ApiController
{
public HttpResponseMessage Get([FromUri] Query query)
{
if (User.IsInRole("admin"))
{
var result = new ValuesController();
return result.Get();
}
}
}
public class ValuesController : ApiController
{
private cdwEntities db = new cdwEntities();
public HttpResponseMessage Get([FromUri] Query query)
{
var data = db.database.AsQueryable();
if (query.name != null)
{
data = data.Where(c => c.Name == query.name);
}
if (query.price != null)
{
data = data.Where(c => c.Price == query.price);
}
if (!data.Any())
{
var message = string.Format("error");
return Request.CreateErrorResponse(HttpStatusCode.NotFound, message);
}
return Request.CreateResponse(HttpStatusCode.OK, data);
}
}
Any advice would be very much appreciated. Many thanks.
|
|
|
|