|
I have following code in a user control in my application
imgbtn2.Click += new ImageClickEventHandler(imgbtn2_Click);
imgbtn2.Command += new CommandEventHandler(imgbtn2_Command);
imgbtn2.Unload += new EventHandler(imgbtn2_Unload);
this code resides in an event handler of another button and imgbtn2 is dynamically created in that event handler.
In fact I only need an event handler for when the ImageButton control is clicked ,but I have about tried anything, but can't find a way to call the event handler. The very weird thing is that the imgbtn2_Unload function is called, but not the other two (Click, Command).
I tried adding the handlers in about every page load event I could find (PreRender, UnLoad, ...) and debugged completely through it. I also tried to create a User Control to be used withing this User Control, but nothing seems to work (the controls, a label and a button remain null ?). I even tried to only start assigning events/properties in the load events (PreRender, UnLoad, ...) of the panel where the controls reside, but nothing works.
So what am I doing wrong here? I've looked around in google, but none of the solutions seem to work.
The goal is to dynamically add controls to a panel.
Many thanks.
V.
|
|
|
|
|
I am getting error when I tried retriving a single row from my LINQ query. This is my code:
Dim query = From mm In dataContext.Mail_Message
Group Join mmr In dataContext.Mail_MessageRecipient On mm.MailMessageId Equals mmr.MailMessageId Into mmrm = Group From mrm In mmrm.DefaultIfEmpty
Group Join u In dataContext.Application_User On mm.SenderId Equals u.UserId Into us = Group From ums In us.DefaultIfEmpty
Group Join sr In dataContext.Personnel_StaffRecord On ums.StaffRecordId Equals sr.StaffRecordId Into srm = Group From smrm In srm.DefaultIfEmpty
Group Join ma In dataContext.Mail_MessageAttachment On mm.MailMessageId Equals ma.MailMessageId Into mam = Group From mamm In mam.DefaultIfEmpty
Where mm.MailMessageId = messageId
Select mrm.MailMessageRecipientId, smrm.Surname, smrm.Firstname, smrm.Othername, mm.Date, mm.Subject, mm.MailContent
If query IsNot Nothing Then
Dim row = query(1)
With result
.MailMessageId = row.MailMessageRecipientId
.Sender = CStr(IIf(row.Surname Is Nothing, "BISM Limited", String.Format("{0} {1} {2}", row.Surname, row.Firstname, row.Othername)))
.Subject = row.Subject
.Body = row.MailContent
.Dates = row.Date
.RecipientNames = GetMailRecipients(messageId)
.Attachments = GetMailAttachments(messageId)
End With
ReadMessage(row.MailMessageRecipientId)
End If
This is the error I get:
LINQ to Entities does not recognize the method 'VB$AnonymousType_48`7[System.Int64,System.String,System.String,System.String,System.DateTime,System.String,System.String] ElementAtOrDefault[VB$AnonymousType_48`7](System.Linq.IQueryable`1[VB$AnonymousType_48`7[System.Int64,System.String,System.String,System.String,System.DateTime,System.String,System.String]], Int32)' method, and this method cannot be translated into a store expression.
What am I getting wrong here?
|
|
|
|
|
Hi,
I'm new in MVC3 and have a simple question. I have Index.cshtml file (view) with 2 controls text box and hyper link:
@Html.TextBox("contId")
@Html.ActionLink("Query", "Query")
In controller class I'd like to have an action that handles clicking hyper link and getting the value of text box above in order to use it in LINQ construction as follows:
public ActionResult Query()
{
int cid = ... ?
var data = from continents in db.Continents
where continents.ContinentID == cid
select continents;
return View(data);
}
The result of LINQ query should be displayed on next view.
Thank you in advance.
Goran
modified 15-Dec-11 0:57am.
|
|
|
|
|
Hello, Execuse me,
I am using Visual Studio 2005 & SQL server 2005.
I am creating web application in C#.
My web project contains membership and role based process.
In database, I created "users" table to keep users' info.
["users" Table does not contain Password column.
It only keeps other info.]
for membership & role, I imported asp.net membership provider schema into my own database.
When I created new user, new user is added into my own "users" table and aspnet Tables such as (aspnet_Users Tables, aspnet_Membership,..and so on).
In my web application, I want to add
UpdateUser function(Updating username, password, email..), DeleteUser function, beside CreateUser function.
for that case,
When I want to delete user,
in my case, I have to delete user from my own table "users" and also delete from aspnet tables.
& also When I want to update,
I have to update user from my own table "users" and also update from aspnet tables.
Therefore, I don't know how I have to solve this problem issue.
I am very confusing
Is it correct ? what I doing, using Both my own table and aspnet membership tables.
OR
do I need to create Custom Membership Provider?
Please give me suggestion for my case.
I just want to be able to create new user, assign Roles, Edit/update user (editing password, username, role, email..)
and delete user for web application.
thanks all.
|
|
|
|
|
I want to insert a row below the Header to put Maximum and Minimum value of every column. Please help... Thank you in advance!
WIND DIR | WIND SPEED (km/hr) | AIR TEMP (C) | AIR HUMIDITY (%) | AIR PRES (millibars) | RAIN AMT (mm) | HOURLY (mm) | RAIN DUR (sec.) | RAIN INT (mm/hr) | DATE TIME |
---|
| max: 5.70 | max: 30.40 min: 23.60 | max: 90.20 min: 64.70 | max: 994.02 min: 990.02 | accum: 0.04 date: 2011 | | max: 30.00 | max: 0.00 min: 0.00 | | 358 | 3.2 | 25.3 | 85.4 | 993.22 | 0 | 0 | 0 | 0.0 | 2011-12-12 23:45:08 | 357 | 3.0 | 25.3 | 85.3 | 993.22 | 0 | 0 | 0 | 0.0 | 2011-12-12 23:30:09 | 008 | 3.0 | 25.4 | 85.2 | 993.22 | 0 | 0 | 0 | 0.0 | 2011-12-12 23:15:09 | 350 | 3.6 | 25.5 | 85.0 | 993.35 | 0 | 0 | 0 | 0.0 | 2011-12-12 23:00:08 |
|
|
|
|
|
Refere this it may help u..
<table cellpadding="1" cellspacing="1" border="1" width="100%" style="height:400px" >
<tr style="height:25px; background-color:Black; color:White;font-family:Tahoma; font-size:11px; vertical-align:middle;">
<th>Project</th>
<th>Description</th>
<th>Amount</th>
</tr>
<asp:Repeater ID="Repeater1" runat="server" >
<ItemTemplate>
<tr style="height:20px;font-family:Tahoma; font-size:11px; vertical-align:middle;">
<td style="padding-left:15px; border-bottom:0px;">
<%# DataBinder.Eval(Container.DataItem, "Project")%>
</td>
<td style="padding-left:15px;border-bottom:0px;">
<%# DataBinder.Eval(Container.DataItem, "Trade")%>
</td>
<td align="right" style="border-bottom:0px;">
<%# DataBinder.Eval(Container.DataItem, "Amount")%>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
<tr>
<td>
</td>
<td>
</td>
<td>
<asp:Label ID="lblTotal1" runat="server"></asp:Label></td>
</tr>
</FooterTemplate>
</asp:Repeater>
<%-- <tr>
<td colspan="3" height="300px"></td>
</tr>--%>
</table>
Ramkumar
("When you build bridges you can keep crossing them. ")
http://ramkumarishere.blogspot.com
|
|
|
|
|
I don't get it "Haven't use repeater before", is there any way to achieve the sample I show here to create a Gridview with subHeader that I can put the Maximum value and Minimum value per column?
The output I want is like if the user selected a date from and date to, it displays the value from date from to date to. Then I will insert First row(Sub header) to put the Maximum value and Minimum Value from the displayed value per column.
|
|
|
|
|
Are you are binding a DataTable to this gridview ? If yes, then add an extra DataRow with the appropriate data at the first position in the datatable.Hope that helps !!!
When you fail to plan, you are planning to fail.
|
|
|
|
|
Hi all,
Currently i am using C#.net 4.0 & JQuery to develop a web project. My problem is I cant invoke the .ashx by using autocomplete(jquery) function. I had done it before in C#.net 3.5 but everything is ok.
below is the sample i done in 4.0:
In UI :
$("[id$='txtApplicant']").autocomplete("../../AutoSuggest.ashx");
In Httphandler :
public void ProcessRequest(HttpContext context)
{
HttpRequest Request = context.Request;
HttpResponse Response = context.Response;
dtResult = getResult(cno,table,field,q);
DataRow[] drs = dtResult.Select();
foreach (DataRow dr in drs)
{
Response.Write(dr["Result"].ToString() + Environment.NewLine);
}
}
Note:
I was put httphandler file outside of the app_code folder (is the must to put in app_code folder?)
and
I din't register any httphandler in web.config
Is something have to configure in web.config?
Any tips or suggest are welcome
Thanks in advance
Cocoonwls
|
|
|
|
|
I have get it work right now. Thanks for those who viewing my post.
Thanks
|
|
|
|
|
This is a volunteer site. People will answer on their time, not yours. Don't be impatient and rude.
If you need immediate help then call Microsoft support and pay
No comment
|
|
|
|
|
Hi Mark,
I don't understand what yours mean but for your information ,since i be a member of this volunteer site, i NEVER (you may view all of my message posted previously...but if you be impatient,you may skip this step )being rude and impatient for others. I am not sure that is any mistake I was made by my previous post then make you comment me like that...but anyway, thanks too because of viewing my question.
p/s: I know if i pay for Microsoft, they will help me immediately. Thanks for your advice.
|
|
|
|
|
hi friends
i am created radiobuttons dynamically
and i am putting it in a list :
say: List<string> lstRadioButton;
i am adding the radiobuttons id to the list and i am also adding the
radio button text and checked value to the list
and on the viewstate(i know that the buttons will not be there)
so i am recreating it with the same id which i got from the list but dont know how to assign the text and checked value
if am doing all these in order to get which of the radio buttons is checked...
hope u got my question.
K.Gayathri
|
|
|
|
|
Hi Gayathri,
In order to get the radiobutton checked state you have to call some event handler on which you might do the coding like this :
Button1_Click(Object sender,EventArgs e)
{
RadioButton rd=(RadioButton)sender;
string id=rd.id;
// It will provide you the Id of RadioButton clicked dynamically.
}
If you are having any other problem, Please post the whole code or mail the code to me on my e-mail id nitisharora007@gmail.com
thanks & regards
Nitish Arora
Web Developer(Learner)
|
|
|
|
|
hi
thanks for the reply
but if i click the button i am not able to get the value(i mean the checked radiobuttons id)
but on post back it says that the radiobuttons do not exist so i have recreated them on every post back but could not make the radiobuttons checked value to be set instead i am able to get only the id.
plz do help me...
stuck with this and not able to proceed further...
K.Gayathri
|
|
|
|
|
hi friends
can anyone help me with this issue plz:
i am creating dynamic radio buttons based on the values i choose from a dropdownlist and if i click the save button i am not able to get the radiobuttons clicked ids so how to do it.....
looking for help....
K.Gayathri
|
|
|
|
|
i am using the following code
RadioButton rdl ;
rdl = (RadioButton)PHEmailfmt.FindControl("rd1") as RadioButton;
if (rdl != null)
{
if (rdl.Checked)
{
Response.Write("rd1 is checked");
}
}
rdl = (RadioButton)PHEmailfmt.FindControl("rd2") as RadioButton;
if (rdl != null)
{
if (rdl.Checked)
{
Response.Write("rd2 is checked");
}
}
rdl = (RadioButton)PHEmailfmt.FindControl("rd3") as RadioButton;
if (rdl != null)
{
if (rdl.Checked)
{
Response.Write("rd3 is checked");
}
}
}
but the find control returns null so can anyone help me plz...
i have created 3 dynamic radio buttons as rd1,rd2,rd3
and on the click of the save button i have the following..
K.Gayathri
|
|
|
|
|
at first, i don't know why you don't use an
<asp:RadioButtonList> it will give you what you want exactly with less effort
if it is:
it would be like that:
<asp:RadioButtonList ID="_radioButtonList" runat="server">
<asp:ListItem Text="text1" />
<asp:ListItem Text="text2" />
</asp:RadioButtonList>
you can create items in it dynamically like this:
ListItem item = new ListItem("Text");
_radioButtonList.Items.Add(item);
and to get SelectedItem , its Text or Value just do like that:
ListItem item=_radioButtonList.SelectedItem;
string selectedItemText=_radioButtonList.SelectedItem.Text;
string selectedItemValue=_radioButtonList.SelectedValue;
you can take SelectedValue in the Save Button Click
Sincerely,
Ibrahim Hebish | SharePoint Software Developer |GlobeSoft(Comp)| EX:EgyptNetwork(Comp)
M: +201281744594
Email: Pronto.cs@gmail.com
|
|
|
|
|
Hi All,
I have a main report with selection formula
i.e if i select employee it will show all the details of employee
later i added subreport with leave information
My requirement is ..
if the user select the employee it should pass the employee name to the subreport stored procedure(c#) as parameter
Please help me with this
Ramkumar
("When you build bridges you can keep crossing them. ")
http://ramkumarishere.blogspot.com
modified 14-Dec-11 6:41am.
|
|
|
|
|
have a gridview on my webpage that binds from an excel sheet using OleDb
Now I'm trying to set it up so that people can search just by typing a word in the textbox, and then after button click, it'd filter all the results that have the same word in any column
I was advised to use this code:
<pre lang="c#">
protected void Button1_Click(object sender, EventArgs e)
{
string search = TextBox1.Text;
OleDbConnection conn = new OleDbConnection(strConn);
conn.Open();
OleDbCommand cmd = new OleDbCommand("SELECT * FROM [Sheet1$]", conn);
OleDbDataAdapter da = new OleDbDataAdapter();
da.SelectCommand = cmd;
DataTable dt = new DataTable();
da.Fill(dt);
grvCarProof.DataSource = dt.Select("CP number = ");
grvCarProof.DataBind();
}
</pre>
what I can't figure out is what kind of writing should go in my SelectCommand(). Am I even doing it right?
Any advice you can give me would be greatly appreciated. Thanks in advance.
|
|
|
|
|
Hi,
I am using just the following piece of code which assigns to an Entity Framework entity.
if (subordinateValueType.TaskTypeId > 0)
{
TaskTypeController taskTypeController = new TaskTypeController();
subordinateValueTypeEntity.TaskType = taskTypeController.GetEntity(subordinateValueType
.TaskTypeId, context, LoadType.Simple);
}
But I am getting the below exception. Can anybody please help me to get rid of the exception. Thanks in advance.
[System.InvalidOperationException] = {"A referential integrity constraint violation occurred: A primary key property that is a part of referential integrity constraint cannot be changed when the dependent object is Unchanged unless it is being set to the association's principal object
Thanks & Regards,
Abdul Aleem Mohammad
St Louis MO - USA
|
|
|
|
|
hi
I want to add a control like textbox when I click a button and new textbox added to the page but when i click the buttom just create one textbox and I lose previus text box
please help me what I shoud do .
|
|
|
|
|
You need to think about the sequence of events (Where and how do you create/recreate the controls) and using ViewState to preserve the control through PostBacks. Found this in under 30 seconds: ow to add and persist controls dynamically[^].
"If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair.
nils illegitimus carborundum
me, me, me
|
|
|
|
|
mark merrens wrote: Found this in under 30 seconds:
isn't google awesome??
as if the facebook, twitter and message boards weren't enough - blogged
|
|
|
|
|
Dear all,
I have the following configuration for my sessionState:
<sessionState mode="InProc" cookieless="UseCookies" timeout="10" >>
It works fine, but there is one thing i don't understand.
When i open multiple tabs, all tabs have the same SessionID, but they don't time out at same time.
I thought that all tabs share the same session, so they have to have also the same timeout
What i want is that ofter session timeout occurs, to logout the user from all opened tabs at the same time.
But in my situaion, when two tabs are open, the first one logs the user out, but not from the second tab. On the second tab, the user still can work.
This is my code to logout and redirect the user ofter session timeout:
protected void Session_Start(object sender, EventArgs e)
{
if (Context.Session != null)
{
if (Context.Session.IsNewSession)
{
string sCookieHeader = Request.Headers["Cookie"];
if ((null != sCookieHeader) && (sCookieHeader.IndexOf("ASP.NET_SessionId") >= 0))
{
FormsAuthentication.SignOut();
HttpContextBase httpContext = new HttpContextWrapper(HttpContext.Current);
UrlHelper urlHelper = new UrlHelper(new RequestContext(httpContext, new RouteData()));
string redirectUrl = urlHelper.Action("LogOn", "Account");
httpContext.Response.Redirect(redirectUrl);
}
}
}
}
How can i solve this issue?
Thanks in advance.
|
|
|
|
|