|
Member 12160780 wrote: . Now If I pressed enter key then message can go Pressing Enter probably is submitting the form so what you can do is google on how to emulate submitting a form with c#. You'll basically do the post yourself.
Social Media - A platform that makes it easier for the crazies to find each other.
Everyone is born right handed. Only the strongest overcome it.
Fight for left-handed rights and hand equality.
|
|
|
|
|
Hi,
I need help to show information in modal.
<pre><div class="modal fade" id="Modalpopup" onclick="Editar" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Modal title</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
Row ID
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save</button>
</div>
</div>
</div>
Function Event click:
eventClick: function (events) {
$('#Modalpopup').modal();
},
<pre><script>
function Editar(id) {
window.location.href = "../Agenda" + id;
}
I have a error in my last code because i use this for show in new page. And now i want show in modal.
|
|
|
|
|
And what is the error?
Social Media - A platform that makes it easier for the crazies to find each other.
Everyone is born right handed. Only the strongest overcome it.
Fight for left-handed rights and hand equality.
|
|
|
|
|
Not a error in display but error where not push information to modal
|
|
|
|
|
I have no idea what that means.
Social Media - A platform that makes it easier for the crazies to find each other.
Everyone is born right handed. Only the strongest overcome it.
Fight for left-handed rights and hand equality.
|
|
|
|
|
You don't actually have any code to show the modal. I don't know what eventClick goes to. And then you have a function which changes the url to a new page. Not sure what that has to do with it.
Social Media - A platform that makes it easier for the crazies to find each other.
Everyone is born right handed. Only the strongest overcome it.
Fight for left-handed rights and hand equality.
|
|
|
|
|
Hi All,
Please provide source code in MVC to display 3 Tabs and display the details in each tab.
For example I need like Emp, Dept, Mgr details. If I click on Emp Tab then Employee details should display, similarly Dept details should display after clicking
on Dept Tab and Manager details should display on click on Mgr tab. All details should display from database.
Please suggest.
Thanks,
SagarPallavi
|
|
|
|
|
This site does not provide code to order. Please do your own research.
|
|
|
|
|
Hi,
I need help for add a new event in full calendar.
I need button ou click in day for open popup where add itens .
<pre><script>
$(function () {
CriarEventosCalendario();
});
function CriarEventosCalendario() {
var events = @Json.Serialize(ViewBag.ListaEventos);
@{
foreach(var item in (List<AgendaModel>)ViewBag.ListaEventos)
{<text>events.push({
'id': @item.Id,
'title': '@item.Title',
'start': '@item.Start',
'end': '@item.End',
'allDay': false,
'color': '@item.Color',
'textColor': '@item.TextColor'
});</text>
}
}
var calendarEl = document.getElementById('calendar');
var calendar = new FullCalendar.Calendar(calendarEl, {
plugins: ['interaction', 'dayGrid'],
header: {
left: 'prevYear,prev,next,nextYear today',
center: 'title',
right: 'dayGridMonth, dayGridWeek, dayGridDay'
},
eventClick: function () {
},
navlinks: true,
editable: true,
eventLimit: true,
selectable: false,
eventClick: function (evenObj, jsEvent, view) {
alert('Event: ' );
},
events: events,
});
calendar.render();
}
</script>
Thanks for your help
|
|
|
|
|
Have you read the documentation? Where exactly are you stuck?
Social Media - A platform that makes it easier for the crazies to find each other.
Everyone is born right handed. Only the strongest overcome it.
Fight for left-handed rights and hand equality.
|
|
|
|
|
Converting pdf files to image so that i can then encrypt the images converted. In my case pdf to jpg. My code will convert each pdf page to an individual image file. So that if the pdf file contains 3 pages I end up with 3 jpg. I then take the 3 images and merge them together to create one big image.
I noticed that if I removed the 3 images from the file system the one bigger image will not display the image. It's as if I removed a reference to the 3 images. And will not display the bigger image properly. Here's the code to convert pdf to images image merge. In this case there are 5 jpg images I merge to one jpg. I don't understand why the merged image will not display the 3 images merged.
Below are the 2 functions to do the convert and merge.
static void PDF2Image()
{
List<string> listOfFiles = new List<string>();
System.Drawing.Bitmap finalImage = null;
int pgs = 0;
System.Drawing.Image img;
string xFile = string.Empty;
FileStream stream;
try
{
string path = @"c:\temp\pdf2Image\";
PdfDocument documemt = new PdfDocument();
documemt.LoadFromFile(@"c:\temp\pdf2Image\DDDDDD.pdf");
pgs = documemt.Pages.Count;
for (int i = 0; i < pgs; i++)
{
img = documemt.SaveAsImage(i, 600, 600);
img.Save(@"c:\temp\pdf2Image\DDDDDD" + "_" + i + ".jpg");
xFile = @"c:\temp\pdf2Image\DDDDDD" + "_" + i + ".jpg";
listOfFiles.Add(xFile);
img.Dispose();
}
documemt.Close();
}
catch (Exception ex)
{
throw;
}
Image2Merge(listOfFiles);
}
public static System.Drawing.Bitmap Image2Merge(List<string> listOfFiles)
{
string imgPath = @"c:\temp\pdf2Image\";
string imgType = "*.jpg";
List<System.Drawing.Bitmap> images = new List<System.Drawing.Bitmap>();
System.Drawing.Bitmap finalImage = null;
int width = 0;
int height = 0;
try
{
foreach (string image in Directory.GetFiles(imgPath, imgType))
{
System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(image);
width += bitmap.Width;
height = bitmap.Height > height ? bitmap.Height : height;
images.Add(bitmap);
}
finalImage = new System.Drawing.Bitmap(5000, height);
using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(finalImage))
{
int offset = 0;
foreach (System.Drawing.Bitmap image in images)
{
image.SetResolution(72, 72);
g.DrawImage(image, new System.Drawing.Rectangle(offset, 0, image.Width, image.Height));
offset += image.Width;
image.Dispose();
}
}
return finalImage;
}
catch (Exception ex)
{
if (finalImage != null)
finalImage.Dispose();
throw;
}
finally
{
finalImage.Save(@"c:\temp\pdf2Image\DDDDDD.jpg", ImageFormat.Jpeg);
foreach (string xFile in listOfFiles)
{
}
}
}
|
|
|
|
|
One issue is that you're hard-coding the width of the final image to 5000 wide rather than using the "width" variable where you've been keeping track of the actual desired width.
|
|
|
|
|
I've done that using the width and height from the foreach loop. But when I pass these vars I get and exception of Parameter is not valid.
|
|
|
|
|
You're getting that error as you don't have enough available memory to hold the image. When you create a bitmap using the constructor that only supplies the width and height;
new System.Drawing.Bitmap(width, height);
the bitmap defaults to a 32-bit colour bitmap so every pixel needs 32bits of memory. If you don't need that many colours you can specify your own colour depth which will reduce the amount of memory used per pixel so you can have bigger images.
finalImage = new System.Drawing.Bitmap(width, height, System.Drawing.Imaging.PixelFormat.Format8bppIndexed);
If that is ok for your image size you can play with the options in PixelFormat to see what the best colour depth you can achieve.
If you google "c# large bitmap" you'll find other discussions about this, if the above doesn't work you might need to do something far more advanced like generate the proper byte streams that constitute a valid image in your desired format, but that will probably require pretty advanced knowledge of jpegs. There might also be a custom library out there that someone has already written to handle large bitmaps.
|
|
|
|
|
Thank you I'll try that now.
|
|
|
|
|
The original pdf pages images are roughly 396kb.
|
|
|
|
|
PDF files aren't stored as bitmaps though. If you take 3k of html in a browser then take a screen shot of the browser it's going to be way bigger than 3k.
|
|
|
|
|
Thank you I appreciate your reply.
I'm not well versed in creation of bitmaps. Bare with me.
Even if your code works I don't think this answers my question. The problem is not creation of the bitmap.
I can create the images from the pdf pages fine. Say I have a pdf with 2 pages. I create two jpg images. I Then create a bigger jpg image to house the two images above. This also works just fine. My last step is to remove "delete" the unneeded two jpg images from above. When my code deletes the two jpg images the merged image no longer works.
|
|
|
|
|
What do you mean by the merged image no longer works? I tried your code and it worked ok. Step through it in the debugger and put a breakpoint on the .Save method of the final image, run that line and check the image is ok via the file explorer. Then step through the loop that deletes the files and see if there is any difference in the saved final image. I tried your code and it worked ok, I'm struggling to see why deleting files after you've saved your merged image would affect that saved image.
|
|
|
|
|
The merged image is where I draw (merge) the images created from the pdf pages.
So if I have a 5 page pdf I will end up with 5 jpgs. I then combine these 5 jpgs onto one big canvas basically another jpg image that houses the 5 images. The original 5 jpgs are then deleted from the file system so that I now end up with just one jpg.
Seems to all be working except when I delete the 5 jpgs the canvas will only show the first page.
|
|
|
|
|
BTW thank you for replying.
|
|
|
|
|
I dynamically create 17 checkbox controls to one div which is set to runat="server" and than I am hiding that div, create the same 17 checkbox's to retrieve the checked value from them and create 30+ dynamically created additional checkbox's in another div.
When I check the first checkbox I created(in the third round of dynamically created checkboxes) and using a method to iterate through them/the second div to check if the first one is indeed checked to true I find out that it is not, ONLY when I get to the 18th checkbox, that I did not checked it is marked checked.
For some reason the creation of the first checkboxes in the second round after postback to the server affects the third round of checkboxes I create, why does it happens? And how to fix it?
|
|
|
|
|
You've got a secret error somewhere in your secret code. You should fix that.
Seriously, how do you think anyone can help you fix your code without seeing the relevant parts of your code?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Because I don't think its connected to my code, its something about dynamic controls or viewstate that I don't understand, and therefore can't answer myself..(I think)
but anyway... here is the code of the page
<pre> <%----%>
<div id ="registrationP3" runat="server" visible="false">
<div id="CheckboxProf" class="radios" runat="server" visible="false" Enableviewstate="false">
</div>
</div>
<%----%>
<div id ="registrationP4" runat="server" visible="false">
<div id="CheckboxProg" class="radios" runat="server" visible="false" EnableViewState="false">
</div>
<asp:Button ID="register" runat="server" Text="Register" OnClick="register_Click" />
</div>
<asp:Button ID="next" runat="server" Text="next" OnClick="next_Click" />
here is the code that creates the checkboxes:
<pre>public static void BindProfessions(HtmlControl ctrl, Page thispage)
{
List<Profession> Plist = Profession.GetProfessionList();
foreach (Profession p in Plist)
{
HtmlInputCheckBox rd_button = new HtmlInputCheckBox();
const string GROUP_NAME = "Professions";
rd_button.Name = GROUP_NAME;
string LinkID = "P" + p.ProfessionID.ToString();
rd_button.Attributes["id"] = LinkID;
rd_button.Value = p.ProfessionID.ToString();
RegisterUserControl userprofession = (RegisterUserControl)thispage.LoadControl("~/RegisterUserControl.ascx");
userprofession.imgP = p.ProfPath;
userprofession.fieldName = p.ProfName;
userprofession.IDnum = p.ProfessionID;
userprofession.RadioName = LinkID;
userprofession.EnableViewState = false;
rd_button.EnableViewState = false;
ctrl.Controls.Add(rd_button);
ctrl.Controls.Add(userprofession);
}
}
public static void BindKnowledge(HtmlControl ctrl, Page thispage)
{
List<Knowledge> Plist = Knowledge.RetKnowledgeList();
foreach (Knowledge p in Plist)
{
HtmlInputCheckBox checkBox = new HtmlInputCheckBox();
const string GROUP_NAME = "knowledge";
checkBox.Name = GROUP_NAME;
string LinkID = "Know" + p.ProgramID.ToString();
checkBox.Attributes["id"] = LinkID;
checkBox.Value = p.ProgramID.ToString();
RegisterUserControl userprofession = (RegisterUserControl)thispage.LoadControl("~/RegisterUserControl.ascx");
userprofession.imgP = p.ProgPath;
userprofession.fieldName = p.PName;
userprofession.IDnum = p.ProgramID;
userprofession.RadioName = LinkID;
userprofession.EnableViewState = false;
checkBox.EnableViewState = false;
ctrl.Controls.Add(checkBox);
ctrl.Controls.Add(userprofession);
}
}
here is the code that checkes the checkboxes after the user clicks submit
<pre> public static List<int> GetCheckBox(HtmlControl ctrl)
{
List<int> id_list = new List<int>();
foreach (Control rdButton in ctrl.Controls)
{
if (rdButton is HtmlInputCheckBox)
{
HtmlInputCheckBox bu = (HtmlInputCheckBox)rdButton;
if (bu.Checked)
{
id_list.Add(int.Parse(bu.Value));
}
}
}
return id_list;
}
here is the Page_Load in which I create the checkboxes once again with BindProfession, pay attention to the third if
protected void Page_Load(object sender, EventArgs e)
{
IsPageRefresh = false;
if (!IsPostBack)
{
ViewState["DivID"] = 1;
ViewState["postids"] = System.Guid.NewGuid().ToString();
Session["postid"] = ViewState["postids"].ToString();
}
else
{
if (ViewState["postids"].ToString() != Session["postid"].ToString())
{
IsPageRefresh = true;
}
Session["postid"] = System.Guid.NewGuid().ToString();
ViewState["postids"] = Session["postid"].ToString();
}
if (int.Parse(ViewState["DivID"].ToString()) == 3)
{
BindProfessions(CheckboxProf, Page);
}
else if(int.Parse(ViewState["DivID"].ToString()) == 4)
{
BindKnowledge(CheckboxProg, Page);
}
}
|
|
|
|
|
Hi, I am trying to get some temperature measurement data that I have stored in a SQL data base over on a webpage through asp.net.
Instead of getting timestamp with temperature measurement numbers I am getting some code text.
Here is my C# code in asp.net
This is Measurement.cs file
Am working in Microsoft Visual studio:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Data.SqlClient;
using Microsoft.JSInterop.Infrastructure;
using Microsoft.AspNetCore.Hosting.Server;
using System.Threading.Tasks;
namespace AirHeaterControlSystem.Models
{
public class Measurement
{
public string Timestamp { get; set;}
public string MeasurementValue { get; set; }
public string ControlValue { get; set; }
public List<Measurement> GetMeasurementParameters()
{
List<Measurement> measurmentParameterList = new List<Measurement>();
string connectionString = "DATA SOURCE=LAPTOP-1T8PALVT\\CITADEL;UID=LAPTOP-1T8PALVT\\AdisP;DATABASE=MEASUREMENTDATA;Integrated Security = True;" ;
SqlConnection con = new SqlConnection(connectionString);
string sqlQuery = "Select Timestamp,MeasurementValue,ControlValue from MEASUREMENTDATA";
con.Open();
SqlCommand cmd = new SqlCommand(sqlQuery, con);
SqlDataReader dr = cmd.ExecuteReader();
if (dr != null)
{
while (dr.Read())
{
Measurement measurementParameter = new Measurement();
measurementParameter.Timestamp = dr["TimeStamp"].ToString();
measurementParameter.MeasurementValue = dr["MeasurementValue"].ToString();
measurementParameter.ControlValue = dr["ControlValue"].ToString();
measurmentParameterList.Add(measurementParameter);
}
}
return measurmentParameterList;
}
}
}
Here is my cshtml file,
@page
@model AirHeaterControlSystem.Pages.MeasurementModel
@{
ViewData["Title"] = "Measurement Parameters";
}
<div>
<h1> Airheater temperature measurement</h1>
<table class="table">
<thead>
<tr>
<th>Timestamp</th>
<th>MeasurementValue</th>
<th>ControlValue</th>
</tr>
</thead>
<tbody>
@foreach (var measurement in Model.measurmentParameterList)
{
<tr>
<td> "measurement.Timestamp</td>
<td> "measurement.MeasurementValue</td>
<td> "measurement.ControlValue</td>
</tr>
}
</tbody>
</table>
</div>
|
|
|
|